ASP.NET MVC: Making routes/URLs IIS6 and IIS7-friendly
Posted
by Seb Nilsson
on Stack Overflow
See other posts from Stack Overflow
or by Seb Nilsson
Published on 2008-09-20T19:10:17Z
Indexed on
2010/06/18
2:43 UTC
Read the original article
Hit count: 355
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.
© Stack Overflow or respective owner