Author: dunmatt | Posted on: 1/2/2009 1:57:08 PM | Views : 363

Hello all. I'm getting some strange behavior from Response.Redirect and I was hoping someone would help me shed some light on it.

I'm working on a login page that will redirect from http://somewhere/login.aspx to https://somewhere/login.aspx if they try to get at it via http. To do so I have the code:

if (Request.ServerVariables["HTTPS"] != "on")
{
Response.Redirect("https://" + Request.ServerVariables["SERVER_NAME"] + Request.ServerVariables["SCRIPT_NAME"], true);
}

The problem I'm seeing is that it infinite loops when I hit it with IE, and it shows "Redirect Loop" when I hit it with Firefox. When I used Network Monitor to look at the traffic as it was flowing by the http headers I saw were all Status 302 (as you'd expect for a redirect), but the "Location:" field only said "/login.aspx"!

So my que ...

Go to the complete details ...