web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Pages
Suggested Answer

Return Login URL

(3) ShareShare
ReportReport
Posted on by 78

Hi,

I’ve been trying to implement a redirect after sign-in that takes the user back to the original page they were viewing before authentication. However, the user is consistently redirected to the profile page instead.

I want to ensure the user is redirected back to the previous page URL, including any appended query parameters or record IDs. I've included the code snippet I'm currently working with (see below).

Can you please advise if this redirection can be handled through site settings, or does it require custom JavaScript or server-side code?

 

Thanks for your help!

 

  <div class="alert alert-danger text-center justify-content-center align-items-center" role="alert"
    style="margin: 0 auto; color: red;">
    <a id="loginLink" href="#"><b>"Click Here TO LOGIN"</b></a>
  </div>
 
 
<script>
  function updateLoginLink() {
    try {
      var currentUrl = window.location.pathname + window.location.search;
      var encodedCurrentUrl = encodeURIComponent(currentUrl);
      var signInUrl = "/SignIn?returnUrl=" + encodedCurrentUrl;
      var loginLink = document.getElementById('loginLink');
      if (loginLink) {
        loginLink.href = signInUrl;
      } else {
        console.error('Login link element not found!');
      }
    } catch (error) {
      console.error('An error occurred while setting the login link:', error);
    }
  }
  document.addEventListener('DOMContentLoaded', function () {
    var loginLink = document.getElementById('loginLink');
    if (loginLink) {
      loginLink.addEventListener('click', function (event) {
        event.preventDefault();
        updateLoginLink();
        window.location.href = loginLink.href;
      });
    }
  });
</script>
Categories:
I have the same question (0)
  • Suggested answer
    Shafiuddin Profile Picture
    74 on at
    Hello,

    This isn’t controlled by a simple site setting, you’ll need the JS workaround (or deeper customization).
  • Suggested answer
    Fubar Profile Picture
    8,491 Super User 2026 Season 1 on at
    I am not 100% sure if this will work for scenario, but there is a Site Setting that forces users to the Profile Page if set to true or not present it will send the user to the Profile Page after sign-in
     
    Authentication/Registration/ProfileRedirectEnabled
     
    set to false to disable the redirection.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
Valantis Profile Picture

Valantis 58

#2
11manish Profile Picture

11manish 55

#3
Vish WR Profile Picture

Vish WR 29

Last 30 days Overall leaderboard