ASP.NET MVC: Making routes/URLs IIS6 and IIS7-friendly
- by Seb Nilsson
I have an ASP.NET MVC-application which I want deployable on both IIS6 and IIS7 and as we all know, IIS6 needs the ".mvc"-naming in the URL.
Will this code work to make sure it works on all IIS-versions? Without having to make special adjustments in code, global.asax or config-files for the different IIS-versions.
bool usingIntegratedPipeline = HttpRuntime.UsingIntegratedPipeline;
routes.MapRoute(
"Default",
usingIntegratedPipeline ?
"{controller}/{action}/{id}" : "{controller}.mvc/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
Update: Forgot to mention. No ISAPI. Hosted website, no control over the IIS-server.