I have tried this in all browsers and works in all - except IE. Here's is the scenario:
in Host A Page 1 we will redirect you to host B when you click a link:
<%@Page Language="C#"%>
<script runat=server>
override protected void OnLoad(EventArgs e)
{
if (Request.QueryString["l"] != null)
Response.Redirect(Request.QueryString["l"]);
}
</script>
<a href="tk.aspx?l=http://HOSTB/landingpage.aspx">redirect to a different domain</a>
</code>
</pre>
In Host B landingpage.aspx, when you arrive without a cookie, we set a cookie and redirect you to the relative url /landingpage.aspx :
<%@Page Language="C#"%>
<script runat=server>
override protected void OnLoad(EventArgs e)
{
if (Request.Cookies["PHPSESSID"] == null)
{
Response.Cookies.Add(new HttpCookie("PHPSESSID", "set"));
Response.Redirect("/landingpage.aspx");
}
}
</script>
<h1>you made it to <% = Request.Url.Host%></h1>
In all browsers I've tried, you arrive at HOSTB/landingpage.aspx. However, in IE, you arrive at HOSTA/landingpage.aspx.
I know what's happening and it's that the relative redirect upon landing on HOSTB is interpreted as relative to the original url's path and normally I would just change the relative url to an absolute one, but here's the rub: I don't contr开发者_JAVA百科ol HOSTB so I can't do that.
Is there any way to make that redirect stick?
For added clarity, here's the entire conversation as seen by fiddler along with the troublesome redirect highlighted using one machine by both IP and Name to substitute for the two domains. You can see that I arrived at 10.0.20.10/landingpage.aspx, but upon that relative redirect, I actually went back to the prior domain XPS730.
I just got the same kind of problem with IE... it seems IE does some bad things when using relative redirection. Try including the whole protocol://domain/ in 'Location' header.
精彩评论