Return to Page after Sign Up or Login

Article author
Duncan Hamra

This article will show you how to return members to the page they were viewing before being asked to sign up or login. This is especially handy if you have a content or functionality that is partially gated (like a blog or comment sections).


Use the attribute data-ms-redirect="current-url" to save the current URL. The next time that visitor goes to sign up or login they will be returned to the page. 

return to page (1).jpg

You can place the attribute anywhere, but we recommend placing it on your signup and login links. 



Stay on page, stay-on page, override redirect, after login, after signup, save page, save url, current url, 

Was this article helpful?



  • Comment author
    Mark Burlinson

    This did not work for us. 

  • Comment author
    Duncan Hamra

    Mark Burlinson Do you have a redirect hard-coded into your signup/login form by chance? 

    I just did some testing and this feature is working as expected for me. It you can share a video or read-only link that would be super helpful to debug 🙏

  • Comment author
    Joseph Carroll
    • Edited

    Duncan Hamra Does this data-ms-redirect attribute work for URL's where there's gated content?

    For context:

    - User clicks on link from email to go specific page

    - Page happens to be gated content (user is not logged in)

    - MS kicks user to log-in page (normal behavior)

    - On log in event --> page redirects from plan level redirects back to original URL they were 'kicked out of'.

    Thanks a mill!


    ++ update ++

    I did add this attribute to the main nav of my web app. (This is a common element across my Member area.)
    This did not work. I understand it should likely be a form element.

    I did try it on my login button on my login *page* (not modal), but obviously that just grabbed the current URL (which was "log-in") which directed me back to itself.

    I have 8+ pages on my web app, sometimes I need to send users straight a specific page (once they log in). I might just hard code this as a cookie and do some logic here if this isn't native to MS. Thanks!

  • Comment author
    Duncan Hamra

    There's no way for it to remember the first page if that page is gated. This attribute only "remembers" the current URL if it is clicked by the member. 

    Thank you for the update! I just tested the attribute on my own site, and it all appears to be working correctly. If the member clicks a link or section with the attribute they will be returned to the page on login. 

  • Comment author
    Joseph Carroll

    Thanks Duncan Hamra! I appreciate the response.


Please sign in to leave a comment.