0

I have a root directory on a web server that is linked to a number of URLs. I want to use the application begin request event of a global.asax file to divert requests to the directories containing the content for the relevant web sites. So in psuedo code terms something like this -

If URL.Contains("www.somthing.com") Then divert user to directory x If URL.Contains("www.somthingelse.com") Then divert user to directory y

I thought I'd be able to accomplish this by just dropping a global.asax file with the relevant code into the web servers root directory (I want to avoid complications such as a web.config file as it's contents will affect other applications I have in sub directories).

Unfortunately, this approach does not seem to work as the application begin request event doesn't appear to fire. I've got round the problem by adding a default.aspx file and making it the default document for the root directory. This appears to work, I presume this is because asp.net compiles the default.aspx file and in turn compiles the global.asax file which allows the events to fire?

Is my workaround the best way to accomplish what I need to do or is there a simpler way to get the global.asax events to fire using a single file?

4

1 回答 1

2

Sounds like you're looking for a Host Header based redirection.

You can accomplish this by configure your ISA Server like this or your IIS like this.

于 2009-08-08T18:56:27.803 回答