I have an asp.net website (.net 4.7.2) which uses Response.Redirect to redirect to some external resources. E.g. https://mypage.com/link?id=1
calls
HttpContext.Current.Response.Redirect("https://anotherpage.com/article.html", false);
HttpContext.Current.ApplicationInstance.CompleteRequest();
This website runs on multiple environments (servers) and on some of them the redirect works correctly, but on some the Location
header appended to response is broken - its value is https://mypage.com/article.html
. So the final URL is a combination of current hostname with the relative path of the reidrect URL. I can't figure out why this happens.
I tried setting the header like this - this didn't make a difference:
HttpContext.Current.Response.StatusCode = 302;
HttpContext.Current.Response.AddHeader("Location", redirectLink);
I want to avoid any client-side hacks like rendering javascript redirect code.
My question is similar to this one: Response.Redirect() is dealing an Absolute URL as an relative URL but I am not using any custom protocols and I am redirecting to simple, properly formatted URLs.
One more note: actually this code worked for last few years and seems that it came up after installing latest April Windows Updates (Windows Server 2016, kb5001347, kb5001402, kb5001649) - but suprisingly after reverting these updates this problem still occurs on these affected environments.