Extension-Less URL Rewriting in IIS6 without 3rd Party ISAPI
That title is a bit of a mouthful, but it sums up the issue. Everyone seems to be talking about hackable URLs these days, and it kind of feels like the RoR guys are laughing at us ASP.NET people. It's just such a pain to get it to work right in ASP. They added the RewritePath method which you can call in a BeginRequest handler to redirect the request to a certain script and add on any querystring you want, totally transparent to the user. It's a good start.
The problem is that BeginRequest only fires for requests that come through to the ASP.NET engine, that means that IIS has to pick up on an extension like aspx which is mapped to that handler. So most examples of URL rewriting will offer a hackable URL like /shop/books/fiction.aspx, I can hear the RoR guys chuckling again.
After a lot of digging around I came across what seems to be a very little known solution, wildcard mapping. Basically you can add an application mapping to '.*' in the application config and all requests will go to the ASP.NET engine.
I found one little reference to this in some blog comments by Scott Guthrie, he said the problem with this solution is you can't override the default document on a folder, but if that document is aspx then it doesn't really matter!
Anyway, I saved myself $99 on ISAPI Rewrite, so I'm happy.
The problem is that BeginRequest only fires for requests that come through to the ASP.NET engine, that means that IIS has to pick up on an extension like aspx which is mapped to that handler. So most examples of URL rewriting will offer a hackable URL like /shop/books/fiction.aspx, I can hear the RoR guys chuckling again.
After a lot of digging around I came across what seems to be a very little known solution, wildcard mapping. Basically you can add an application mapping to '.*' in the application config and all requests will go to the ASP.NET engine.
I found one little reference to this in some blog comments by Scott Guthrie, he said the problem with this solution is you can't override the default document on a folder, but if that document is aspx then it doesn't really matter!
Anyway, I saved myself $99 on ISAPI Rewrite, so I'm happy.
Labels: aspnet, urlrewrite


follow me on Twitter!
Comment Feed


I am newbie and want to do it for my website. Can you tell me how i can make my link /med.aspx?cat=rose become /med/rose. I am running iis6
Can you elaborate more on this? I can't seem to find where the configuration part to change.