RedirectFromLoginPage

Discussion in 'ASP .Net' started by Shawn, Apr 23, 2004.

  1. Shawn

    Shawn Guest

    Hi.
    I'm using RedirectFromLoginPage to redirect the user if the login was
    successful. The problem is that I don't want the user to be redirected to
    the page he requested. I want him to be redirected to my startup page. Is
    that possible?


    Thanks,
    Shawn
     
    Shawn, Apr 23, 2004
    #1
    1. Advertising

  2. Shawn,

    When you authenticate the user, you can perform a Response.Redirect to your
    startup page and just ignore the RedirectFromLoginPage method.

    Hope this helps!

    Christopher Reed
    Web Applications Supervisor
    City of Lubbock
    "The oxen are slow, but the earth is patient."

    >>> Shawn<> 4:31:31 AM 4/23/2004 >>>

    Hi.
    I'm using RedirectFromLoginPage to redirect the user if the login was
    successful. The problem is that I don't want the user to be redirected to
    the page he requested. I want him to be redirected to my startup page. Is
    that possible?


    Thanks,
    Shawn
     
    Christopher Reed, Apr 23, 2004
    #2
    1. Advertising

  3. Shawn

    Shawn Guest

    If I simply replace RedirectFromLoginPage with Response.Redirect then the
    page I'm redirecting to just sends me back to the login page again.. I'm
    guessing I somehow have to tell FormsAuthentication that the user has been
    authenticated.. Can you tell me how?

    Shawn


    "Christopher Reed" <> wrote in message
    news:...
    > Shawn,
    >
    > When you authenticate the user, you can perform a Response.Redirect to

    your
    > startup page and just ignore the RedirectFromLoginPage method.
    >
    > Hope this helps!
    >
    > Christopher Reed
    > Web Applications Supervisor
    > City of Lubbock
    > "The oxen are slow, but the earth is patient."
    >
    > >>> Shawn<> 4:31:31 AM 4/23/2004 >>>

    > Hi.
    > I'm using RedirectFromLoginPage to redirect the user if the login was
    > successful. The problem is that I don't want the user to be redirected to
    > the page he requested. I want him to be redirected to my startup page. Is
    > that possible?
    >
    >
    > Thanks,
    > Shawn
    >
    >
    >
    >
     
    Shawn, Apr 23, 2004
    #3
  4. Shawn,

    Try this:

    void LoginBtn_Click(Object sender, EventArgs e)
    {
    if (Page.IsValid)
    {
    // Call the authentication event handler delegate (not included
    in this example).
    if (FormsAuthentication.Authenticate(UserName.Text,
    UserPass.Text))
    {
    // Return to the originally requested URL.
    Response.Redirect("mystartpage.aspx");
    }
    else
    {
    Msg.Text = "Invalid Credentials: Please try again";
    }
    }
    }

    Hope this helps!


    Christopher Reed
    Web Applications Supervisor
    City of Lubbock
    "The oxen are slow, but the earth is patient."

    >>> Shawn<> 5:09:00 PM 4/23/2004 >>>

    If I simply replace RedirectFromLoginPage with Response.Redirect then the
    page I'm redirecting to just sends me back to the login page again.. I'm
    guessing I somehow have to tell FormsAuthentication that the user has been
    authenticated.. Can you tell me how?

    Shawn


    "Christopher Reed" <> wrote in message
    news:...
    > Shawn,
    >
    > When you authenticate the user, you can perform a Response.Redirect to

    your
    > startup page and just ignore the RedirectFromLoginPage method.
    >
    > Hope this helps!
    >
    > Christopher Reed
    > Web Applications Supervisor
    > City of Lubbock
    > "The oxen are slow, but the earth is patient."
    >
    > >>> Shawn<> 4:31:31 AM 4/23/2004 >>>

    > Hi.
    > I'm using RedirectFromLoginPage to redirect the user if the login was
    > successful. The problem is that I don't want the user to be redirected

    to
    > the page he requested. I want him to be redirected to my startup page.

    Is
    > that possible?
    >
    >
    > Thanks,
    > Shawn
    >
    >
    >
    >
     
    Christopher Reed, Apr 23, 2004
    #4
  5. Shawn

    benedict79

    Joined:
    Jul 22, 2009
    Messages:
    1
    No, no, no.

    FormsAuthentication.RedirectFromLoginPage(string username, bool isCookiePersistent)

    This method do two actions:
    1. sets the authentication cookie to response so server reconize you in the future
    2. redirects to requested or default page

    If you do not want to redirect user to requested page, you can use Response.Redirect method instead, but before calling it you have to set auth cookie by executing:

    FormsAuthentication.SetAuthCookie(string username, bool isCookiePersistent)

    isCookiePersistent is true if you do not want authentication to expire in some time period, and default is false.

    Why not FormsAuthentication.Authenticate?

    Because, that method do only user credentials verification and you can use it only if you use web.config as user credential store.
     
    Last edited: Jul 22, 2009
    benedict79, Jul 22, 2009
    #5
    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. Gan
    Replies:
    2
    Views:
    482
    venkat
    Jun 27, 2003
  2. TaeHo Yoo
    Replies:
    1
    Views:
    544
    Teemu Keiski
    Jul 9, 2003
  3. Lauchlan M
    Replies:
    2
    Views:
    511
    John Saunders
    Aug 17, 2003
  4. Eric Broers
    Replies:
    1
    Views:
    821
    Steve C. Orr [MVP, MCSD]
    Nov 27, 2003
  5. .NET Follower
    Replies:
    2
    Views:
    671
    .NET Follower
    Feb 4, 2004
Loading...

Share This Page