Most .NET examples for URL rewriting use HTTPModules or HTTPHandlers rather than actual ISAPI filters. (Yes, there is still a diffrence.)
The big problem with this is the fact that the URL calls for the rewrites have to trigger a .NET call to the ASP.NET ISAPI filter to even have your HTTPModule or HTTPHandler to be launched.
That means that your URL file extension needs to be .aspx, .asmx, .asax, .ascx, .ashx, .axd. But what if you want a redirect based on .gif, .swf, .xml? Sorry you are out of luck. But not realy.
If your rewrite code is generic enough, you can rewrite these too by telling IIS to use the ASP.NET Isapi filter on these files.
Step by step below:
- From IIS console, go to your application directory and open the properties window.
- Go to the “Home Directory” tab
- Click on “Configuration” Button
- On the “Mappings” tab you will set your Isapi filters.
- We will now map SWF to the ASP.NET Isapi filter.
- Click Add
- Enter “c:\winnt\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll” into the executable path. (This is for the 2.0 framework.)
- Type your extension like “.swf”. No leading wild cards. Do not forget to put in the leading period before the actual extension.
- Leave script engine checked.
- Uncheck “Verify if file exists”
- As a minimum, verb should be get, but with static items, I may put all, and use the rewriter to block writes. Then I can control posting by user rights.
That is it. It only took me too many hours in one day to discover all of this.
Note: This was ASP.NET 2.0 and IIS 6.0. I have not tried this on the 3.0 framework or on any pre-releases of the IIS 7.0.