Forked Login Implementation -- How to do this?

Discussion in 'ASP .Net' started by Steve Commisso, Apr 20, 2005.

  1. I'm trying to create a forked login where users of certain roles will be
    redirected to specific pages.

    The easy way to do this would be to do the redirecting in the
    Page_Load() of the default page after login, but I'd like to skip this
    step and just have the Login control go ahead and do it.

    So my plan is this: override the OnLoggedIn() method of the Login
    control with my own custom method that changes the DestinationPageUrl
    property of the Login control.

    Here's the code (in my code-behind page, Login.aspx.cs):

    void OnLoggedIn(object sender, EventArgs e)
    {
    if (System.Web.Security.Roles.IsUserInRole ("engineers"))
    Login1.DestinationPageUrl = "Engineering.aspx";
    else
    Login1.DestinationPageUrl = "Default.aspx";
    }

    Here's the ASP code for the control (Login.aspx):

    <asp:Login ID="Login1" Runat="server"
    OnLoggedIn=OnLoggedIn
    </asp:Login>


    I'm running into a few problems:

    1) I know my method is overloading properly because whatever I put for
    the Url under the 'else' statement is where I'm redirected to. This
    means that the IsUserInRole() method is always returning false -- but
    isn't the OnLoggedIn() method supposed to fire right after the user is
    validated? Because of this, shouldn't the IsUserInRole() method work
    since there's a current user to check?

    2) If I'm redirected to the Login page so that there's a ReturnURL="..."
    in the address bar, that ReturnURL seems to override the
    DestinationPageURL property, which I thought I had read overrides all
    default redirections. I guess this is wrong?


    So basically, is it feasible to do this 'forking' via the Login control?
    Or am I going to have to do it somewhere else.

    Thanks in advance,
    Steve Commisso

    *** Sent via Developersdex http://www.developersdex.com ***
    Steve Commisso, Apr 20, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RL
    Replies:
    2
    Views:
    596
  2. Replies:
    2
    Views:
    8,714
    Sebastian Scheid
    Aug 25, 2005
  3. Replies:
    2
    Views:
    423
    Chris Croughton
    Apr 13, 2005
  4. John Lin
    Replies:
    19
    Views:
    569
    Donn Cave
    Sep 25, 2003
  5. Donn Cave
    Replies:
    2
    Views:
    511
    MrEntropy
    Jul 15, 2005
Loading...

Share This Page