views:

618

answers:

3

Hi,

I have a scenario that my load balancer translates port 80 from outside into port 801 which is local. And When it comes to server, server obviously sees port 801 and in Response.Redirect it tries to inject port 801 into the URL it redirects to but this is not the desired solution for me.

What I am thinking is to: 1. Overwrite Response.Redirect so that I remove the port from it. 2. Have some kind of configuration in web.config to ignore that port. 3. The most nasty way of fixing the problem is to change the whole application to use full URL's inside Response.Redirect which is a big pain.

Is there a good solution to this problem?

Environment: Windows Vista, Windows 2003 Server, Windows 2008 Server IIS 6, IIS 7 ASP.NET C# & VB.NET

A: 

Do you need it to be a redirect, or can you just use Server.Transfer()?

Chris Dwyer
I needed to be redirected actually.
SevDer
A: 

Redirect it to the original hostname so it goes through the load balancer, without any explicit port. The redirected is built (or can be built) programmatically, so you should be able to avoid the problem.

ka3751
That is what we are doing anyway but port gets into the picture. And I have so many redirects already (hundreds of them)
SevDer
+4  A: 

Ok,

I got the answer myself. I hope this solution will be useful for others too.

Well, the answer is within the web.config. Under

<system.web>
<httpRuntime useFullyQualifiedRedirectUrl="false" maxRequestLength="2526" requestLengthDiskThreshold="2526"/>
</system.web>

where the important part is the following to be false.

useFullyQualifiedRedirectUrl="false"

This is true by default.

SevDer