Sunday, April 13, 2008

Deployed ASP.NET MVC app gives 404 on About Page

I am working through learning how to use the ASP.NET MVC framework with a web application. One of the annoying problems that I recently hit on was that the sample worked great when running under Cassini in the development environment but when deployed to IIS 6 I couldn't get to the About or Home page through the URL paths.

The following comment exists in the Global.asax.cs file:

            // Note: Change the URL to "{controller}.mvc/{action}/{id}" to enable
            //       automatic support on IIS6 and IIS7 classic mode

When running in Cassini you don't need to make this change. However, under IIS 6, if you forget to make this change then you'll hit this problem and get 404 page-not-found errors. Simply making this change appears to solve the problem.

I read some comments on the web that you need to add .mvc as a MIME type with a mapping of C:\WINDOWS\MICROSOFT.NET\FRAMEWORK\V2.0.50727\ASPNET_ISAPI.DLL which I tried initially with no success and then later went back and removed it when I got it working with the above solution. The MIME types don't appear to be the solution.

This was done with the MVC preview 2 released in Dec 2008.


I found that on Server 2003 Enterprise (Dev Machine) I did not need to map .mvc to C:\WINDOWS\MICROSOFT.NET\FRAMEWORK\V2.0.50727\ASPNET_ISAPI.DLL but when I deployed to Production (Server 2003 Standard) I had to go into the web site's properties and click Home Directory (tab) and then Configuration... (button) and then add the mapping. I thought that this was an Enterprise/Standard thing but then on closer inspection I discovered that the Enterprise machine already had this mapping. This probably happened when I installed the MVC preview onto the Enterprise (Dev) machine and it looks like (contrary to what I said before) you do need this mapping.

Addendum 2: (27 Oct 2008):

Since I've upgraded to mvc beta I've found that the above fixes don't work for me - they may still work for you. I've found the following resources useful so far:

Deploying ASP.NET MVC to IIS 6

Using ASP.NET MVC on IIS without the .MVC extension



  1. Guy,
    I've been fighting this problem now for a while and can't figure it out. I'm on Vista (64 bit) and made a MVC app that is MVC2 and .Net 4.0. I've set up the App Pool and website on IIS 7, but for whatever reason, I get the 404 error. Right now my site does engage the web.config, it does throw the custom 404 page, but I can't seem to get it to display the site. I'm guessing it's a routing issue, but I'm not sure. I developed in VS 2010 and I also did the "wildcard mappings" on the IIS server... any other advice???

  2. Hi J - you shouldn't need to do the wildcard mappings on the IIS server if the server is IIS7.
    I would try the following:
    - Remove the wildcard mappings.
    - Check that the App Pool is set to .Net 4 (it probably defaults to .Net 2 so you have to explicitly set it to .Net 4 if it's a .Net 4 app that you've compiled.)
    - Confirm that you haven't changed the default controllers and views (if you have moved them to new locations then you are correct that you would need to edit the routing in the global.asax.cs file.)