binary dreams

a world of 1s and 0s

Steps I follow when creating a new ASP.NET MVC 5 website

I thought it best I start to list the steps I follow when I create a brand new MVC 5 website and why

I thought it best I start to list the steps I follow when I create a brand new MVC 5 website and why. These steps could well be used with previous versions of ASP.NET MVC, I leave that up to you.

Enable deployment to Windows Server 2008

If you are deploying your website to Windows Server 2008 then you will need to add this configuration to your web.config:

<system.web>
    <httpRuntime targetFramework="4.5" />
</system.web>

This is required because the IIS AppPool for your website is still referring to .NET v4 and cannot be upgraded but the website is actually .NET v4.5

Using bootstrap v3

Bootstrap v3 comes out of the box in MVC 5 but you still need to register the woff file type.

<system.webServer>
    <staticContent>
      <mimeMap fileExtension="woff" mimeType="application/font-woff" />
    </staticContent>
</system.webServer>

Add custom error pages

Add your own custom errors as follows:

<system.web>
    <customErrors mode="On" defaultRedirect="~/Error">
      <error statusCode="401" redirect="~/Error/Unauthorised" />
      <error statusCode="403" redirect="~/Error/AccessDenied" />
      <error statusCode="404" redirect="~/Error/NotFound" />
      <error statusCode="500" redirect="~/Error/Index" />
    </customErrors>
</system.web>

It is highly recommended that you enable the use of custom errors with your website. You want to show a friendly error message.