Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange #_=_ appear at the end of url after response.redirect ASP.NET

Anyone here using Response.Redirect() method, do have you encountered some strange characters attached to the end of the uri on the browser address bar?
The strange characters are hash, underscore, equal sign and underscore (without spaces) such as below... I have no idea what are these all about and when these strange characters appear, the redirection didn't happen properly.

 #_=_ 

Any insights on this please share. Thanks

like image 423
FBLover2011 Avatar asked Oct 03 '11 07:10

FBLover2011


2 Answers

Anything in the location-part of a URL that follows a # refers to an anchor in the page, usually an <a name=""> or <whatever id="">. Some web sites use them (probably with client-side Javascript) to perform magic, but since you are asking this, I get the feeling that's not the case for you. So, there's no real rhyme or reason to that the existence or absence of those characters in and of themselves would cause the redirection to work or not. In fact, they aren't even sent to the server in the HTTP request (at least, Firefox doesn't).

Have you had a look at the HTTP request exchanges when this is happening? Something like Live HTTP Headers, HttpFox or Firebug (look at the Net panel) will help you with this, and might point you to where the errant #_=_ is coming from.

like image 97
user Avatar answered Oct 09 '22 19:10

user


Here's my solution based on a couple others out there:

$(function () {
    if (window.location.href.indexOf("#_=_") > -1) {
        //remove facebook oAuth response bogus hash
        if (window.history && window.history.pushState) {
            history.pushState('', document.title, window.location.pathname);
        } else {
            window.location.href = window.location.href.replace(location.hash, "");
        }
    }
});

https://stackoverflow.com/a/7845639/1467810

https://stackoverflow.com/a/15323220/1467810

https://stackoverflow.com/a/2295951/1467810

like image 37
TaeKwonJoe Avatar answered Oct 09 '22 21:10

TaeKwonJoe