locked
ASP.NET identity 2.2.1 returnUrl with hash value ? RRS feed

  • Question

  • User592395570 posted

    I m using identity to do facebook login 

    when facebook callback and my server sign in with the user and finally redirect to "ReturnUrl" .

    https://localhost:44301/#_=_  <-- the url auto include the hash sysbol  #_=_ 

    can somebody tell me why and how to remove it.

    Monday, February 15, 2016 4:38 AM

Answers

  • User614698185 posted

    Hi Yam,

    keatkeat

    do you mean this is a facebook issue not ASP.NET right ? 

    From this link: https://developers.facebook.com/blog/post/552/

    It says: We started adding a fragment #_=_ to the redirect_uri when this field is left blank. Please ensure that your app can handle this behavior.

    Best Regards,

    Candice Zhou

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 18, 2016 9:05 AM

All replies

  • User614698185 posted

    Hi keatkeat,

    You could use Javascript to fix it:

    <script type="text/javascript">
        if (window.location.hash && window.location.hash == '#_=_') {
            if (window.history && history.pushState) {
                window.history.pushState("", document.title, window.location.pathname);
            } else {
                // Prevent scrolling by storing the page's current scroll offset
                var scroll = {
                    top: document.body.scrollTop,
                    left: document.body.scrollLeft
                };
                window.location.hash = '';
                // Restore the scroll offset, should be flicker free
                document.body.scrollTop = scroll.top;
                document.body.scrollLeft = scroll.left;
            }
        }
    </script>

    For more information, please see:

    http://stackoverflow.com/questions/7131909/facebook-callback-appends-to-return-url

    https://github.com/jaredhanson/passport-facebook/issues/12#issuecomment-5913711

    Best Regards,

    Candice Zhou

    Tuesday, February 16, 2016 3:08 AM
  • User592395570 posted

    hi Candice Zhou,

    Thank you for reply. 

    1 more question is why it happend ?

    do you mean this is a facebook issue not ASP.NET right ? 

    Regards

    Yam

    Wednesday, February 17, 2016 9:54 AM
  • User614698185 posted

    Hi Yam,

    keatkeat

    do you mean this is a facebook issue not ASP.NET right ? 

    From this link: https://developers.facebook.com/blog/post/552/

    It says: We started adding a fragment #_=_ to the redirect_uri when this field is left blank. Please ensure that your app can handle this behavior.

    Best Regards,

    Candice Zhou

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 18, 2016 9:05 AM
  • User592395570 posted

    Thank a lot for you !!

    Regards 

    Yam

    Friday, February 19, 2016 2:53 PM