thinking in geek tagline’s are so web2.0

Posted
26 April 2007 @ 10am

Tagged
castle, iis

Monorail + URL Rewriting

Often people need or want clean URLs (i.e. URL’s without file extensions). e.g.

Not
http://example.com/somecontroller/someaction.aspx
but
http://example.com/somecontroller/someaction

Previously there’s been two options for this. Either mapping all requests to aspnet_isapi.dll which has serious performance implications - or using ISAPI Rewrite from Helicon Software.

There’s a newish (to me anyway) alternative to ISAPI rewrite which is open source (BSD) Ionics Isapi Rewrite Filter - It’s got some really nice features that ISAPIRewrite doesn’t have. Specifically it supports the following setup:

RewriteCond %{REQUEST_FILENAME}     !-f
RewriteCond %{REQUEST_FILENAME}     !-d
RewriteRule ^.*$     /default.aspx     [U,I,L]

This checks the incoming request does not match an existing file/directory on the filesystem before it rewrites the request.

This is a feature that apache users have had in mod_rewrite forever - but it’s really helpful for us IIS users because it avoids all the overhead associated with mapping all requests to the aspnet_filter.dll. You can leave IIS configured as it is and any incoming requests which do not refer to existing files ( e.g. stylesheets/images/javascripts etc) will be processed by the ASP.NET runtime where the monorail can take them over.


No Comments Yet


There are no comments yet. You could be the first!

Leave a Comment

Turtles all the way down and the CLR (or JVM) FormsAuthentication AppPool restarts and machineKeys