Deploying ASP.NET MVC 3 to IIS 6

I recently built a new ASP.NET MVC 3 (.NET 4) web application which unfortunately has be hosted on Windows Server 2003 running IIS 6. Guess I’d figured getting it running on IIS 6 would be as easy as installing .NET 4 and ASP.NET MVC 3 on the server… but it wasn’t. This isn’t a step by step tutorial on how to get this working, but more of a list of things to look out for and some links to helpful material which all helped getting my site up and running.

Installations

  • Install the .NET 4 Framework.
  • Install ASP.NET MVC 3. Apparently you can avoid installing ASP.NET MVC 3 on the server and just deploy all the appropriate MVC assemblies in the bin folder of your app instead, but I couldn’t get this to work.

IIS Configuration

  • Make sure ASP.NET v4.0.30319 is ‘Allowed’ under Web Service Extensions in IIS – it is ‘Prohibited’ by default.
  • Create a new app pool for your web site to use – IIS 6 app pools cannot run sites under different frameworks so make sure this app pool is only used for your new site.

IIS Website Configuration

Right click on your new website and select ‘Properties’:

  • Under the ‘ASP.NET’ tab, make sure that the ASP.NET version is set to ‘4.0.30319’.
  • Under the ‘Home Directory’ tab, make sure that ‘Execute permissions’ is set to ‘Scripts only’ (at least).
  • Click on the ‘Configuration’ button in the ‘Home Directory’ tab and make sure that all the Application extensions are mapped to .NET 4 versions of the dlls.
  • Add a ‘Wildcard application mapping’ – click on ‘Insert’ and enter ‘C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll’ as the ‘Executable’. Leave ‘Verify that file exists’ unchecked – checking this made my routes stop working.

Permissions

If you’re running under an account with limited permissions, you may need to grant it ‘List Folder Contents’ and ‘Read’ permissions on the Windows Temp directory. I needed to do this because I’m calling out to web services and .NET creates temporary classes in the Windows Temp directory with which to serialize objects from XML. Not sure if this is needed if you’re not doing any serializations, but worth mentioning.

Conclusion

I kept getting 403 and 404 errors when I first deployed my new ASP.NET MVC 3 (.NET 4) web application to IIS 6, but after doing / checking all of the above, it all seems to be working smoothly.

And last but not least: if you’re allowed to, try recycling your application pool and resetting IIS if some changes don’t seem to be making much difference.

Useful links

http://haacked.com/archive/2010/12/22/asp-net-mvc-3-extensionless-urls-on-iis-6.aspx
http://johan.driessen.se/posts/getting-an-asp.net-4-application-to-work-on-iis6
http://blog.stevensanderson.com/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/

If you liked this post, share it!
Facebook Twitter Linkedin Delicious Digg Stumbleupon Email

42 thoughts on “Deploying ASP.NET MVC 3 to IIS 6

  1. I am new to web application develoment and needed to deploy mvc 3 app on iis 6 and got problem. Luckily I found this post. Thanks.

  2. Thanks Annie. This article saved my day at work today. Even after installing MVC3, and following all steps you had listed in this article. I was receiving HTTP 500 error instead of a HTTP 403 or HTTP 404. I had no issues with UAT environment, but the problem was with our PROD; looks like it was locked down for more things. There wasn’t any reliable source for fixing this issue except yours, which is detailed and well written.

    The one thing that is missing in this article is I had to add *.asax mapping to ‘C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll’, even though ‘Wildcard application mapping’ was entered.

    Thanks again.

  3. Thanks. Actually we don’t need to install MVC3 on the IIS 6 Server, right click the web project, click add Deployable Dependencies, check ASP.NET MVC and ASP.NET Web Pages with Razor syntax (if you use it)will copy the required assembly to bin folder.

  4. Hi Annie, thanks for your post it solved my issue on deploying my ASP.Net MVC 3 app on IIS 6.0 with multiple .Net versions running. I researched and read lots of possible solutions but nothing works until I read your post. My app is just a virtual site running under .Net version 4.0 and the root site is under .Net version 1.1. If I change the root from 1.1 to 4.0, existing virtual sites running under .Net 2.0 breaks but my MVC app runs with no error and If I bring back the root site to .Net 1.1 my MVC app breaks, gave me error 403 others runs okay. I followed all the instructions for setting-up extensionless URL’s still getting 403 error. Only I found out, on this article that i missed one step which is “Add Wildcard Application Mapping”. After adding that, my MVC app runs with no error, same thing with other virtuals sites running under 2.0 and 1.1. Again, thank you for giving us the light on this issue.

  5. It’s 5:30 in the morning, I’m right in the middle of a deployment to an old Windows Server 2003 server.

    Although my MVC 3 app worked fine out of the box, it looked like crap, because IIS was serving 404 for my LESS files (using dotless.)

    Your last bullet was a sure shot (pun intended)

    I owe you a beer! ;-)

  6. Hi,

    I tried all of your steps. Now I am confident that IIS is allocating a .NET 4 app pool to get requests on this site. But there is an issue with permissions.
    Now when i try to browse to the web site, I get a message saying :

    Configuration Error

    An error occured in loading the configuration file. Access to the path
    C:\Inetpub\....\web.config is denied .

    Any ideas to fix this ?

    • Hmm… Are you running your .NET 4 app pool under a particular user with locked down permissions? Perhaps that user doesn’t have read access to the application folder? If I think of anything else I’ll reply again… :)

  7. “Leave ‘Verify that file exists’ unchecked – checking this made my routes stop working.”

    Thanks so much, that was the thing I was missing and I’ve been stuck on this for a couple hours. That step got everything working.

  8. I follewed the steps many times. I keep getting 403 on the root and 404 on any action. I use integrated windows authentication and I see in the logs it goes without a problem. I have researched the subject a lot. Your post sums it all up very well, but it still does not work for me. Any suggestions what might be the reason?

  9. Thank you for your excellent post. I spent yesterday afternoon working on this and was completely stuck until I followed your advice and got it working.

  10. Thank you very much for this post. It works
    I have noticed also that if I look back under the Configuration button of the Home Directory under IIS, the Wildcard application maps remains empty.
    I have added one just as it is mentioned in your post.

    How about getting ASP.NET MVC 4 to work in IIS 6?

  11. Thank you very much for this post. I was trying to fix error since last two days finally i have got your post. Its really helpful.

  12. ABOUT WILCARD APPLICATION MAP: Be aware that this option causes IIS to intercept every request made against the web server. This includes requests for images, classic ASP pages, and HTML pages. Therefore, enabling a wildcard script map to ASP.NET does have performance implications.

    OTHER SOLUTION: In W2K3 SP2 with IIS6, .NET Framework (2, 3.5, 4).

    Goto Registry:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\4.0.30319.0

    If is necesary create DWORD EnableExtensionlessUrls with value 0.

    Then from command window execute: resetiis

    Create a ASP.NET application from MVC3 Template.

    Now in the global.asax setup the routes like theses:

    public static void RegisterRoutes(RouteCollection routes)
    {
    routes.IgnoreRoute(”{resource}.axd/{*pathInfo}”);

    //routes.MapRoute(
    // “Default”, // Route name
    // ”{controller}.mvc/{action}/{id}”, // URL with parameters
    // new { controller = “Home”, action = “Index”, id = “” } // Parameter defaults
    //);
    routes.MapRoute(
    “Default”,
    ”{controller}.aspx/{action}/{id}”,
    new { action = “Index”, id = “” }
    );
    routes.MapRoute(
    “Root”,
    “”,
    new { controller = “Home”, action = “About”, id = “” }
    );
    }

    Create AppPool for .NET Framework 4 and setup the web application to use this apppool. You can use the Denis Bauer’s ASP.NET Version Switcher or use Aspnet_regiis.exe.

    RESULT: the browser shows de About page as the default page.

  13. Thank you very much.

    Your post really help me to make my application up…

    I went with the option on not deploying the ASP.net MVC on the server

  14. Thanks very much for this! The thing that my colleague and I hadn’t tried was:

    “Add a ‘Wildcard application mapping’ – click on ‘Insert’ and enter ‘C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll’ as the ‘Executable’. Leave ‘Verify that file exists’ unchecked – checking this made my routes stop working.”

    Making this change instantly resolved a problem which had persisted for a whole week, and was about to see us re-write the whole site in ASP.NET web forms if we hadn’t got a result this afternoon. :O

    Nice one. :)

Leave a Reply

Your email address will not be published. Required fields are marked *