+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Simple Login not redirecting

Simple Login not redirecting

7 posts, 0 answered
  1. David
    David avatar
    22 posts
    Registered:
    04 May 2009
    08 Jun 2009
    Link to this post
    I created a dead simple page and added a login control.

    I have other pages redirecting to that page when auth is required.  In testing these protected pages, it redirects to my login page and has a ReturnUrl.

    However, when I sign in successfully, no redirect occurs.  It stays on the login page with the ReturnURL sitting up in the querystring just smiling at me.
  2. David
    David avatar
    22 posts
    Registered:
    04 May 2009
    08 Jun 2009
    Link to this post
    Follow-up....

    I can see that the cookie is getting set properly.  As expected, if I manually go back to the protected page it doesn't send me back to the login page.
  3. David
    David avatar
    22 posts
    Registered:
    04 May 2009
    08 Jun 2009
    Link to this post
    It seems everything would be fine if I could dynamically set the Login control's DestinationPageUrl as in...

    string returnUrl = Request.Params["ReturnUrl"]; 
    if (!String.IsNullOrEmpty(returnUrl)) 
        Login1.DestinationPageUrl = returnUrl; 

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    09 Jun 2009
    Link to this post
    Hi David,

    You could also add the following logic in the Login control. We use the standard ASP.NET login control.

    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);  
            }  
            else  
                this.Response.Redirect("somewhere_else");  
        }  


    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Garry Clark
    Garry Clark avatar
    26 posts
    Registered:
    27 Jan 2005
    24 Jun 2009
    Link to this post
    David,
    Did you resolve this as I am seeing the same behavoir. I have a simple login page and when the user is authenticated it does not redirect to the DestinationPageUrl I set. Matter a fact it does not even appear that the login control is persisting my DestinationPageUrl as everytime I go to edit the control it is blank.

    Do I need to set this manually?

    Any thoughts?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    24 Jun 2009
    Link to this post
    Hi Garry Clark,

    The problem with the DestinationPageUrl property is related to the selector that you are using to choose a page. If you type the property value manually your url will be persisted.
    Another option is exposing the property on the first level as below:

     
        [WebEditor("Telerik.Cms.Web.UI.UrlEditorWrapper, Telerik.Cms")] 
        public string DestinationPage 
        { 
            get 
            { 
                return this.Login1.DestinationPageUrl; 
            } 
            set 
            { 
                this.Login1.DestinationPageUrl = value; 
     
            } 
        } 


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. David
    David avatar
    22 posts
    Registered:
    04 May 2009
    24 Jun 2009
    Link to this post
    My issue turned out to be something different than the solution described.

    The DestinationURL had to match the login url in my web.config.

    See more links here: http://stackoverflow.com/questions/966833/by-default-does-asp-net-login-control-use-the-returnurl-to-redirect/
Register for webinar
7 posts, 0 answered