Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to overwrite Response.Redirect to prevent port coming with it

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

like image 206
SevDer Avatar asked Oct 27 '25 14:10

SevDer


1 Answers

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.

like image 154
SevDer Avatar answered Oct 29 '25 04:10

SevDer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!