For a request to:
http://domain.com/
when referenced from the Begin_Request
event in an HttpModule
:
HttpContext.HttpRequest.Url.AbsolutePath == "/"
... Url.AbsoluteUri = "http://domain.com/"
... Url.LocalPath = "/"
If you're not seeing those values from Application_BeginRequest
, you might need to register a separate HttpModule
. Global.asax events are only called for managed HttpHandlers
, so they may not be called until after IIS does an internal redirect (transfer) to "/default.aspx".
You may also need to disable default document handling in IIS for this to work in the direction you're interested in (most sites redirect from /
to /default.aspx
, not the other way around).
Edit: another idea. Register a new extension as an ASP.NET page handler, with a build provider (in web.config) -- maybe *.asph or something like that. Then rename your existing default.aspx
to default.asph
. Next, add default.asph
to the top of the list of default files in IIS, replacing default.aspx
. Create a new default.aspx
file, whose only function in the code behind is to redirect to /
. That should do it.