views:

1077

answers:

2

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.

A: 

You can use an ISAPI filter to rewrite URLs which will allow you to have the nice URLs while still on IIS 6.

Look, for example, here

alex
+3  A: 

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