I would like to re-route traffic in HTTP request from one server to another in an ASP.NET web site. I have been looking into trying to do this using an http module or http handler. Are these viable options for my case or does anyone have a better recommendation? This application is using .NET 4.0 Framework and is host on IIS6.
Asked
Active
Viewed 276 times
1 Answers
0
In addition to the comment above, I wanted to provide a small snippet of code. You should be able to do this in your HTTPModule with Response.Redirect. I am not 100% certain but I believe that the RewritePath method may throw a platform not supported exception on IIS6. IIS6 definitely support Response.Redirect fortunately.
Go ahead a handler for begin request:
{
context.BeginRequest += new EventHandler(MyBeginRequestMethod);
}
Then in your begin request method:
HttpApplication application = (HttpApplication)sender;
HttpContext context = application.Context;
if(context.Request.FilePath.Contains("someresource"))
{
context.Response.Redirect("http://www.google.com");
}
Obviously you will be able to do some more comprehensive look-up of content and a more complete redirect this way.

Timothy Randall
- 17,634
- 1
- 15
- 27