Deploying MVC on IIS 6

If and when you have to deploy your MVC application, you’ll soon find out that IIS6 does not support Url Rewriting.  There are a number of options available to you, for a good list check out Steve Sanderson’s Deploying ASP.NET MVC to IIS 6, the one I’m currently using is:


Use a wildcard mapping for aspnet_isapi.dll

This tells IIS 6 to process all requests using ASP.NET, so routing is always invoked, and there’s no problem. It’s dead easy to set up: open IIS manager, right-click your app, go to Properties, then Home Directory tab, then click Configuration. Under Wildcard application maps, click Insert (not Add, which is confusingly just above),  then enter C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll for “Executable”, and uncheck Verify that file exists.

Done! Routing now just behaves as it always did in VS2008’s built-in server.

Unfortunately, this also tells IIS to use ASP.NET to serve all requests, including for static files. It will work, because ASP.NET has a built-in DefaultHttpHandler that does it, but depending on what you do during the request, it might use StaticFileHandler to serve the request. StaticFileHandler is much less efficient than IIS natively. You see, it always reads the files from disk for every request, not caching them in memory. It doesn’t send Cache-Control headers that you might have configured in IIS, so browsers won’t cache it properly. It doesn’t do HTTP compression. However, if you can avoid interfering with the request, DefaultHttpHandler will pass control back to IIS for native processing, which is much better.

For small intranet applications, wildcard mappings are probably the best choice. Yes, it impacts performance slightly, but that might not be a problem for you. Perhaps you have better things to worry about.

For larger public internet applications, you may need a solution that delivers better performance.

Snippet taken from Steve Sanderson’s Deploying ASP.NET MVC to IIS 6


For more information take a look at ScottGu’s blogTip/Trick: Url Rewriting with ASP.NET

Also worth taking a look at Phil Haacked articles on ASP.NET MVC on IIS 6 Walkthrough