[SOLVED] How to overwrite Response.Redirect to prevent port coming with it

Issue

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

Solution

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.

Answered By – SevDer

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *