Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

ReWritePath / Application_BeginRequest Question

Following code in global.asax.cs:

protected void Application_BeginRequest(Object sender, EventArgs e)
HttpContext context = HttpContext.Current;

this only works if the url has an aspx extension.  Is there any other way to accomplish url rewriting with a different extension (or none at all)? 

Thursday, February 19, 2004

You need to convince your web server (presumably IIS) to send all requests to the ASP.NET engine. How you do this, depends on what version of IIS you're using.

Open IIS Admin, drill into your virtual directory, and get properties. Configure the application. Delete all the default ISAPI mappings. For IIS 5.x (2000/XP), you'll add a mapping for .* to aspnet_isapi.dll (in \Windows\Microsoft.NET\Framework\v1.x.xxxx); for IIS 6, there's a special section for "default mappings", which you'll set as aspnet_isapi.dll. Uncheck the option that reads something like "Ensure file exists" (which tells the web server not to look for some file on disk, but just dispatch any URLs at all to you).

Being more specific would take a LONG time to explain. Hopefully you can muddle your way through. :)

Brad Wilson (
Thursday, February 19, 2004

Brad: Thank you.  I had been poking around in the mapping already and your instructions were perfectly clear.

Thursday, February 19, 2004

One other option - if you're using IIS6 - is to write a wildcard ISAPI application mapping. The SDK samples provide the URL rewriting functionality you're looking for.

Greg Hurlman
Friday, February 20, 2004

Greg: that's exactly what I described.

Brad Wilson (
Friday, February 20, 2004

Some useful stuff on URL rewriting here on IanG's blog here
and here

Duncan Smart
Monday, February 23, 2004

*  Recent Topics

*  Fog Creek Home