Many thanks to Duncan Smart whose comment on my previous post about deploying ASP.NET MVC applications to IIS 6 gives us a further option. It turns out that even though IIS Manager only lets you configure wildcard maps on a per-application level, IIS itself allows you to configure them on a per-directory level.
Recap: The goal here is to deploy ASP.NET MVC applications to IIS 6, keeping the clean, extensionless URLs (which requires a wildcard map so that all URLs are processed by ASP.NET, or some tricky URL-rewriting), but without incuring the performance penalty of letting static files get processed by ASP.NET. See the previous post for more details.
So, if you can be disciplined and keep all your static content inside your /Content folder, you can use a normal wildcard map at the root level to get ASP.NET MVC to handle all incoming URLs, even without any “filename extensions” in the URLs, but then also disable that wildcard map on the /Content folder and below, allowing those static files to be processed natively by IIS (which performs much better).
How to set it up
First, deploy your application and use a wilcard map as explained before. Next, find out the “identifier” of your application by looking at IIS Manager:
Now, to remove the wildcard map on the /Content subdirectory, open a command prompt, go to c:\Inetpub\AdminScripts, and run:
adsutil.vbs SET /W3SVC/105364569/root/Content/ScriptMaps ""
… replacing 105364569 with the “identifier” number of your application. (Also, you could replace “Content” with the path to any other directory.)
That does it! Your /Content folder will now bypass the wildcard mapping, and its files will be served natively by IIS.
If you don’t like to use adsutil.vbs, you can achieve the same by exploiting what appears to be a bug in IIS Manager. Turn your subdirectory into an application (from its Directory tab, click “Create”). Then edit its script mappings to remove aspnet_isapi.dll. Then go back and “Remove” the application you just created. The metabase’s new ScriptMaps value will be retained, even though the option has now disappeared from the GUI.