Introduction
I often map html extention to the asp.net dll in order to use url rewritter with .html extentions. Recently, in the new version of www.nouvelair.ca, we renamed all urls to end with .html. This works great, but failed when we used FCK Editor. Static html files would not get serve because we mapped the html extension to the .NET Framework. We can we do to to use .html extension with our rewritter but still want to use IIS behavior with static html files.
Analysis
I thought that this could be resolve with a simple HTTP handler. We would map urls of static files in our rewriter to this handler that would read the static file and serve it, just as IIS would do.
Implementation
This is how I coded the class. Note that this may not be bullet proof. I only tested it once and I am sure that the logic behind IIS is more complicated that this. If you find errors or think of possible improvements, let me know.
See the full source code and article at http://www.developerit.com/2010/03/16/fake-isapi-handler-to-serve-static-files-with-extention-that-are-rewritted-by-url-rewriter
Conclusion
As you see, with our static files map to this handler using query string (ex.: /ISAPIDotNetHandler.ashx?fileUri=index.html) you will have the same behavior as if you ask for the uri /index.html.
Finally, test this only in IIS with the html extension map to aspnet_isapi.dll. Url rewritting will work in Casini (Internal Web Server shipped with Visual Studio) but it’s not the same as with IIS since EVERY request is handle by .NET.
Versions
- First release
Published on http://www.developerit.com/
> 2010-04-01T10:34:34Z, (4/1/2010 9:53:07 PM UTC)
How can 10:34 become 9:53?????
developerit.com is loaded with such errors.
There is a difference between the time on which an article is published on the web (2010-04-01T10:34:34Z which is 10:34 am UTC) and the time where Developer IT‘s robot index this article (at 9:53 pm). Maybe we should add a bit of description to explain which date means what…
Thanks for your comment 🙂