Here are 7 simple tips to help you improve your .NET website:

  1. Script and style bundling and minification

    Bundling and minification are two techniques you can use in ASP.NET 4.5 to improve request load time. Bundling and minification improves load time by reducing the number of requests to the server and reducing the size of requested assets.

    See my article for how to do this.

  2. Render Script and CSS Sections

    To keep your code tidy and to add code to sections of the page from lower level templates, it is good practice to render sections.

    See Scott Gu's blog post for examples of this.

  3. Always add a favicon

    You should always add a favicon. Lots of browsers look for it by default even if it is not referenced on the page, they look for it at the root of your site. If you have a high-traffic site, your server will generate a 404 error for each first request of it.

    Read this article to find out more.

  4. Redirect to www

    I prefer to have my domain running from a www address so I create a rewrite rule to direct requests that don't have a www at the beginning to the address with it on. There is talk that it is better to redirect www to the address without it these days, but I still think it is better to go to www. Whichever you chose, make sure all of your traffic goes to one. 
    Read this article in google support pages to find out more about why this is a good idea.

    Read my article for how to do this in Umbraco.

  1. Custom 404 and 500 error pages

    You should set up a custom error page for 404 errors and one for 500 errors. The 404 page will be used when a page isn't found and sometimes for minor errors when you can still serve the custom 404 error page. The 500 error will be used when there is a server error.

    To get this set up in my sites, I create a page called error, just under the homepage. I get the source of this page create a 500.html page and save it at the root of my site.
    In the web.config for the site you can add the following to enable these custom errors:

    <!-- inside system.web -->

    <customErrors mode="On" redirectMode="ResponseRewrite">
          <error statusCode="404" redirect="/Error"/>
          <error statusCode="500" redirect="/500.html"/>
        </customErrors>


    <!-- inside system.webServer -->

            <httpErrors errorMode="Custom" existingResponse="Replace">
                <remove statusCode="404" subStatusCode="-1"/>
                <remove statusCode="500" subStatusCode="-1"/>
                <error statusCode="404" prefixLanguageFilePath="" path="/Error" responseMode="ExecuteURL"/>
                <error statusCode="500" prefixLanguageFilePath="" path="/500.html" responseMode="ExecuteURL"/>
            </httpErrors>
  2. XML Sitemap

    XML Sitemaps help search engines find pages faster, reducing the amount of time it takes to index your site.

    Have a read of my blog post to find out how to create one in Umbraco

  3. Robots.txt

    This is a text file at the root of your site which tells search engine crawlers like google which pages in your site it can or can't crawl. It also tells them where your sitemap is.

    Here is a useful article to help you understand them.

Another good way to improve your .NET websites, is to go through some of the video courses on Pluralsight. If you use this link, you will get a 10 day free trial.

I hope this helps you with building your websites, please do let me know if it does by commenting. Please also feel free to comment if you have any other good tips.

Want to thank me?

If I've helped you out and you want to thank me, why not buy me a coffee?

Paul Seal

A .NET Web Developer from Derby (UK) who specialises in building Content Management System (CMS) websites using MVC with Umbraco as a framework. Paul is passionate about web development and programming as a whole. Apart from when he's with his wife and son, if he's not writing code, he's thinking about it or listening to a podcast about it.

Web: codeshare.co.uk

Comments

Share Top