PDA

View Full Version : Weird behavior with hashes in the URL + redirecting



chinabuffet
9 Mar 2011, 4:41 PM
In the application I'm working on, there is extensive use of the Ext.History object for history management, so there is almost always a hash in the URL. Sometimes during page generation at the server, I need to redirect the user somewhere else (perhaps to a login page if their session has expired or something). The problem is that the hash in the URL is persisted across redirects for some reason in non IE browsers. This doesn't really seem to be a direct problem with Ext JS probably, but perhaps with how browsers handle the hash when redirecting? The example below demonstrates this problem:



// Test.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!loggedIn) {
Response.Redirect("http://www.yahoo.com");
}

// continue page generation...
}


say you hit Text.aspx#asdf directly, and you are not logged in...

you are then actually taken to:

http://www.yahoo.com/#asdf

This behavior also happens via redirects through servlet response's sendRedirect as well. These methods of redirects appear to just use the http Location header, which when looking at the Http spec for it, doesn't mention anything about hashes in the URL, or persisting them for some reason.

Any ideas on why this might be happening? Is there some other additional header or something I can set so that the hash is not persisted during a redirect?