Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Mar 31, 2011 @ 13:41
    Ismail Mayat
    0

    redirect url after logging in

    Guys,

    I have extranet setup and on a page in my site i list these protected pages.  

    Clicking on them as expected takes me to my login page. This has macro using loginview control and in anonymous template i have Login control.  All works fine except for one thing what i want to do is set the destination url so that after logging in they get redirected to the protected page the initially tried to hit. 

    How would i do this on load event pick up the refer page?

    Regards

     

    Ismail

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Mar 31, 2011 @ 13:45
    Matt Brailsford
    0

    Doesn't the login control automatically do this using the ReturnUrl Querystring parameter?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Mar 31, 2011 @ 13:45
    Dirk De Grave
    0

    Ismail,

    I'm bit surprised that you'd need to set the destination url, it should all be taken care of by the login control, shouldn't it? Don't you get that weird ?returnUrl on the querystring when you're taken to the login page? I've never had to set the destination url explicitely?

     

    Cheers,

    /Dirk

  • Jonas Eriksson 930 posts 1825 karma points
    Mar 31, 2011 @ 13:47
    Jonas Eriksson
    1

    Hi Ismail,

    I spent some (somewhat painful) hours with this all kinds of approaches for this the other week, here's what worked out for me for a login script:

    [edited]

    var requestedUrl = Request.Url.PathAndQuery.ToString();
      if (Request["ReturnUrl"]!=null)
      {
        requestedUrl = Request["ReturnUrl"];
      }

    string username=Request["username"];
    string password=Request["password"];

    if (Membership.ValidateUser(username, password))
    {
      // RedirectFromLoginPage does not work that good within the Umbraco context
      // FormsAuthentication.RedirectFromLoginPage(username, true);
      FormsAuthentication.SetAuthCookie(username, true);
      // Redirect to / refresh the requested page
      Response.Redirect(requestedUrl);
    }
  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Mar 31, 2011 @ 13:58
    Ismail Mayat
    0

    Dirk and Matt,

    You would think however say i have secured page http://mysite/securepage.aspx that goes to the login page but the url is still http://mysite/securepage.aspx now i am positive if in the page_load of login control i was to get current node i would get the login page and not the securepage. which is why i asked should i get refer page instead and set that as destination url. Jonas may give your reponse a go.

    Regards

    Ismail

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Mar 31, 2011 @ 16:07
    Ismail Mayat
    0

    Jonas,

    That did it many thanks mate.

    Regards

    Ismail

  • Jonas Eriksson 930 posts 1825 karma points
    Mar 31, 2011 @ 16:12
    Jonas Eriksson
    0

    Ah, nice,

    cheers

    Jonas

  • Andrei 2 posts 22 karma points
    Aug 19, 2011 @ 11:44
    Andrei
    0

    Thanks Jonas,

    good work!

  • Jonas Eriksson 930 posts 1825 karma points
    Aug 19, 2011 @ 12:51
    Jonas Eriksson
    0

    Cool, glad it helped - your post reminded me that I should update the package file with the new source, so it's easier to install. So I just did that now. Also added a screencast showing a basic member login setup. http://our.umbraco.org/projects/website-utilities/razorlogin

Please Sign in or register to post replies

Write your reply to:

Draft