More in this section

Forums / Developing with Sitefinity / Login Page for Users

Login Page for Users

2 posts, 0 answered
  1. Jackson
    Jackson avatar
    51 posts
    23 May 2008
    02 Dec 2008
    Link to this post
    I created a login page for users and want to be able to have it do the return URL so if they are trying to leave a comment and need to login it will return them to the page they were on.

    Is there a simple way to do this?

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    03 Dec 2008
    Link to this post
    Hi Chris Morrow,

    Thank you for using our services.

    Here is a solution to your request.

    First you could check whether the user is authenticated or not when trying to access restricted area.

     if (!Page.User.Identity.IsAuthenticated) 
                // redirect to the login sign up page 
            e.Item.NavigateUrl = "~/Login.aspx?ReturnUrl=" + e.Item.NavigateUrl; 

    Then in your login control you should get the http query string variables and redirect the user to the last used page. In the example below I am using standard login control.

    public partial class UserControls_FinalLoginControls_LoginControl : UserControl 
        void Page_Load(object sender, EventArgs e) 
            this.Login1.LoggedIn += new EventHandler(Login1_LoggedIn); 
        void Login1_LoggedIn(object sender, EventArgs e) 
            string redirectUrl = Request.QueryString["ReturnUrl"]; 
            if (!string.IsNullOrEmpty(redirectUrl)) 
                redirectUrl = HttpUtility.UrlDecode(redirectUrl); 
                this.Response.Redirect(redirectUrl, true); 

    I hope this helps.

    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
2 posts, 0 answered