When you run your ASP.NET MVC application in Visual Studio's built-in web server, it works fine. But when you try to deploy it to a Windows 2003 system (or any other IIS 5 or 6 based web server), you will get a "404 Not found" error. This is due to the reason that on IIS 6 (or prior versions) ASP.NET is only executed if the URL contains a filename extension (such as .aspx) which mapped to aspnet_isapi.dll. Since ASP.NET MVC uses .NET based URL routing in the form of "http://www.mysite.com/Home/Index" instead of traditional .aspx filename extensions. Unfortunately you can't use .NET based routing without .NET being executed.
There are several solutions to this problem of which some would require to partially rewrite the application. Please note that ASP.NET MVC requires .NET 3.5 SP1 and the ASP.NET MVC runtime to be installed on your web server. If this is not the case and you don't have your own server, you will have manually import the assemblies in your application's bin folder.
Solution 1: Upgrade to IIS 7 (Windows Server 2008)
II7 supports .NET HttpModules by default, so you wouldn't have to make changes to your application or server configuration at all. This is the easiest , but also the most impossible solution (unless you have your own dedicated server).
Solution 2: Change your route entries' patterns
In the most cases you will probably run your application in a shared hosting scenario. In this case you can easily solve the problem by adding the .aspx extensions to your routes' URL patterns. The following shows how to adapt global.asax:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default",
"{controller}.aspx/{action}/{id}", // .aspx added
new { controller = "Home", action = "Index", id = "" }
);
}
The disadvantage of this solution is that this mutilates your clean URL schema.
Solution 3: Add a IIS wildcard mapping
If you have access to your IIS configuration, there is another alternative: Open your web application's Properties window in the IIS manager and click on Configuration (to found on the Home Directory tab).
Insert a new wildcard application map with your aspnet_isapi.dll path (usually C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll) as Executable. Please make sure that the checkbox is unchecked.
This causes the IIS to process all requests (independent of the filename extension) with ASP.NET. Unfortunately this can result in performance problems.