It took me a bit, but I figured out how to make the extensions work with IIS 6. First, you need to rework the base routing to include .aspx so that they will be routed through the ASP.NET ISAPI filter.
routes.MapRoute(
"Default", // Route name
"{controller}.aspx/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
If you navigate to Home.aspx, for example, your site should be working fine. But Default.aspx and the default page address of http://[website]/ stop working correctly. So how is that fixed?
Well, you need to define a second route. Unfortunately, using Default.aspx as the route does not work properly:
routes.MapRoute(
"Default2", // Route name
"Default.aspx", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
So how do you get this to work? Well, this is where you need the original routing code:
routes.MapRoute(
"Default2", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
When you do this, Default.aspx and http://[website]/ both start working again, I think because they become successfully mapped back to the Home controller. So the complete solution is:
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}.aspx/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
routes.MapRoute(
"Default2", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
protected void Application_Start()
{
RegisterRoutes(RouteTable.Routes);
}
}
And your site should start working just fine under IIS 6. (At least it does on my PC.)
And as a bonus, if you are using Html.ActionLink() in your pages, you should not have to change any other line of code throughout the entire site. This method takes care of properly tagging on the .aspx extension to the controller.
From the readme word doc for RC1 (not indexed by google)
ASP.NET Compiler Post-Build Step
Currently, errors within a view file are not detected until run time. To let you detect these errors at compile time, ASP.NET MVC projects now include an MvcBuildViews property, which is disabled by default. To enable this property, open the project file and set the MvcBuildViews property to true, as shown in the following example:
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MvcBuildViews>true</MvcBuildViews>
</PropertyGroup>
Note Enabling this feature adds some overhead to the build time.
You can update projects that were created with previous releases of MVC to include build-time validation of views by performing the following steps:
- Open the project file in a text editor.
- Add the following element under the top-most
<PropertyGroup>
element:
<MvcBuildViews>true</MvcBuildViews>
- At the end of the project file, uncomment the
<Target Name="AfterBuild">
element and modify it to match the following:
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)\..\$(ProjectName)" />
</Target>
Best Answer
That should fix the .mvc problem since the integrated pipeline is IIS7 strictly. But remember to change settings on the IIS7 website to use "2.0 Integrated Pipeline" otherwhise it will return false aswell. Also ofcouse setup the mapping of .mvc to the asp.net isapi dll, but Im guessing that you already know this.
Some small suggestions on other things you might need to remember when deploying MVC applications on IIS6 that I found useful: http://msmvps.com/blogs/omar/archive/2008/06/30/deploy-asp-net-mvc-on-iis-6-solve-404-compression-and-performance-problems.aspx