URL rewriting

  • Thread starter Thread starter Juha Borenius
  • Start date Start date
J

Juha Borenius

I read Robert Chartier's article from 15 seconds
(http://www.15seconds.com/issue/030522.htm) and tried it myself. URL
rewriting seems to work fine as long as original file exists. For example:
redirecting from /mysample/default.html to /mynewsample/default.html works
when original file exists. But when original file doesn't exist or request
file is not specified (requesting for a directory /mysample/), IIS throws an
error. Seems that HttpModule doesn't get OnBeginRequest -event at all.

Is there any way to work around this problem?
Is there any ready ISAPI filters for URL rewriting?

Regards,
Borre
 
Use Global_PreRequestHandlerExecute method in Global.asax.
This fires for every request, there you can write your code to create
the URL and use response.redirect

Ram
 
AFAIK, the ASP.Net engine only handles the request if it is mapped as the
handler for the file type. Since fake directories are not mapped to any
handler, the IIS 404 mechanism takes care of it. You would need to configure
IIS to use a custom 404 page in order to have all possibilities handled by
your code.

Also see MSDN Magazine from August 2002. There is an article by Panos
Kougiouris about this topic.

Colin
 
Back
Top