Login - return back to original page

Discussion in 'ASP .Net' started by =?Utf-8?B?U2FuZHk=?=, May 18, 2005.

  1. Hello -

    I have two places in my application where someone needs to be logged in. If
    they are not logged in and I send them to the login page, how do I send them
    back to the page they originally came from after they log in?

    Any help will be greatly appreciated!
    --
    Sandy
    =?Utf-8?B?U2FuZHk=?=, May 18, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?U2FuZHk=?=

    Lucas Tam Guest

    "=?Utf-8?B?U2FuZHk=?=" <> wrote in
    news::

    > I have two places in my application where someone needs to be logged
    > in. If they are not logged in and I send them to the login page, how
    > do I send them back to the page they originally came from after they
    > log in?


    ASP.NEt's Forms authentication handles URL redirection for you.

    --
    Lucas Tam ()
    Please delete "REMOVE" from the e-mail address when replying.
    http://members.ebay.com/aboutme/coolspot18/
    Lucas Tam, May 18, 2005
    #2
    1. Advertising

  3. After you authenticate the user, you can call
    FormsAuthentication.RedirectFromLoginPage

    This will automagically redirect the user back to the page they want to
    access.
    --
    Tu-Thach


    "Sandy" wrote:

    > Hello -
    >
    > I have two places in my application where someone needs to be logged in. If
    > they are not logged in and I send them to the login page, how do I send them
    > back to the page they originally came from after they log in?
    >
    > Any help will be greatly appreciated!
    > --
    > Sandy
    =?Utf-8?B?VHUtVGhhY2g=?=, May 18, 2005
    #3
  4. Hi Tu-Thach!

    Thanks for your response!

    I tried including this in my code, but couldn't get it to work.

    Here's my code. Where is it supposed to go? I kept getting the squiggly
    blue line when I tried to put it in. At the top of the page, I included
    Imports System.Web.Security

    Private Sub btnSubmitLogin_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles btnSubmitLogin.Click
    Dim daTest as SqlDataAdapter
    Dim dsLogin as New DataSet
    daTest = New SqlDataAdapter("Select UserID from " _
    & "tblLogin Where " _
    & "UserName = '" & txtUserName.Text _
    & "' and Password = '" & txtPassword.Text _
    & "'", cnn)

    daTest.Fill(dsLogin, "tblLogin")
    If dsLogin.Tables("tblLogin").Rows.Count = 0 then
    lblLoginStatus.Text = "User name and password not found. Please try
    again."
    Else
    Session("UserID") = dsLogin.Tables("tblLogin").Rows(0).Item("UserID")
    lblLoginStatus.Text = "Success!"

    End If
    End Sub

    --
    Sandy


    "Tu-Thach" wrote:

    > After you authenticate the user, you can call
    > FormsAuthentication.RedirectFromLoginPage
    >
    > This will automagically redirect the user back to the page they want to
    > access.
    > --
    > Tu-Thach
    >
    >
    > "Sandy" wrote:
    >
    > > Hello -
    > >
    > > I have two places in my application where someone needs to be logged in. If
    > > they are not logged in and I send them to the login page, how do I send them
    > > back to the page they originally came from after they log in?
    > >
    > > Any help will be greatly appreciated!
    > > --
    > > Sandy
    =?Utf-8?B?U2FuZHk=?=, May 18, 2005
    #4
  5. Hi Tu-Thach!

    I tried including it in my code but couldn't get it to work. It just
    redirected to default.aspx (which I don't even have).

    Can you be more explicit on how to use it?

    Here's my code:

    Private Sub btnSubmitLogin_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles btnSubmitLogin.Click
    Dim daTest as SqlDataAdapter
    Dim dsLogin as New DataSet
    daTest = New SqlDataAdapter("Select UserID from " _
    & "tblLogin Where " _
    & "UserName = '" & txtUserName.Text _
    & "' and Password = '" & txtPassword.Text _
    & "'", cnn)

    daTest.Fill(dsLogin, "tblLogin")
    If dsLogin.Tables("tblLogin").Rows.Count = 0 then
    lblLoginStatus.Text = "User name and password not found. Please try
    again."
    Else
    Session("UserID") = dsLogin.Tables("tblLogin").Rows(0).Item("UserID")
    'I put it in here. Something's obviously wrong
    FormsAuthentication.RedirectFromLoginPage(txtUserName.Text,
    Remember.Checked)
    End If
    End Sub


    --
    Sandy


    "Tu-Thach" wrote:

    > After you authenticate the user, you can call
    > FormsAuthentication.RedirectFromLoginPage
    >
    > This will automagically redirect the user back to the page they want to
    > access.
    > --
    > Tu-Thach
    >
    >
    > "Sandy" wrote:
    >
    > > Hello -
    > >
    > > I have two places in my application where someone needs to be logged in. If
    > > they are not logged in and I send them to the login page, how do I send them
    > > back to the page they originally came from after they log in?
    > >
    > > Any help will be greatly appreciated!
    > > --
    > > Sandy
    =?Utf-8?B?U2FuZHk=?=, May 18, 2005
    #5
  6. After your success check lblLoginStatus.Text = "Success!", you can add this
    line

    FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false);

    That will redirect the user to the page they want access.

    --
    Tu-Thach


    "Sandy" wrote:

    > Hi Tu-Thach!
    >
    > Thanks for your response!
    >
    > I tried including this in my code, but couldn't get it to work.
    >
    > Here's my code. Where is it supposed to go? I kept getting the squiggly
    > blue line when I tried to put it in. At the top of the page, I included
    > Imports System.Web.Security
    >
    > Private Sub btnSubmitLogin_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles btnSubmitLogin.Click
    > Dim daTest as SqlDataAdapter
    > Dim dsLogin as New DataSet
    > daTest = New SqlDataAdapter("Select UserID from " _
    > & "tblLogin Where " _
    > & "UserName = '" & txtUserName.Text _
    > & "' and Password = '" & txtPassword.Text _
    > & "'", cnn)
    >
    > daTest.Fill(dsLogin, "tblLogin")
    > If dsLogin.Tables("tblLogin").Rows.Count = 0 then
    > lblLoginStatus.Text = "User name and password not found. Please try
    > again."
    > Else
    > Session("UserID") = dsLogin.Tables("tblLogin").Rows(0).Item("UserID")
    > lblLoginStatus.Text = "Success!"
    >
    > End If
    > End Sub
    >
    > --
    > Sandy
    >
    >
    > "Tu-Thach" wrote:
    >
    > > After you authenticate the user, you can call
    > > FormsAuthentication.RedirectFromLoginPage
    > >
    > > This will automagically redirect the user back to the page they want to
    > > access.
    > > --
    > > Tu-Thach
    > >
    > >
    > > "Sandy" wrote:
    > >
    > > > Hello -
    > > >
    > > > I have two places in my application where someone needs to be logged in. If
    > > > they are not logged in and I send them to the login page, how do I send them
    > > > back to the page they originally came from after they log in?
    > > >
    > > > Any help will be greatly appreciated!
    > > > --
    > > > Sandy
    =?Utf-8?B?VHUtVGhhY2g=?=, May 19, 2005
    #6
  7. Tu-Thach -

    Thank you so much! Really appreciated!
    --
    Sandy


    "Tu-Thach" wrote:

    > After your success check lblLoginStatus.Text = "Success!", you can add this
    > line
    >
    > FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false);
    >
    > That will redirect the user to the page they want access.
    >
    > --
    > Tu-Thach
    >
    >
    > "Sandy" wrote:
    >
    > > Hi Tu-Thach!
    > >
    > > Thanks for your response!
    > >
    > > I tried including this in my code, but couldn't get it to work.
    > >
    > > Here's my code. Where is it supposed to go? I kept getting the squiggly
    > > blue line when I tried to put it in. At the top of the page, I included
    > > Imports System.Web.Security
    > >
    > > Private Sub btnSubmitLogin_Click(ByVal sender As System.Object, ByVal e As
    > > System.EventArgs) Handles btnSubmitLogin.Click
    > > Dim daTest as SqlDataAdapter
    > > Dim dsLogin as New DataSet
    > > daTest = New SqlDataAdapter("Select UserID from " _
    > > & "tblLogin Where " _
    > > & "UserName = '" & txtUserName.Text _
    > > & "' and Password = '" & txtPassword.Text _
    > > & "'", cnn)
    > >
    > > daTest.Fill(dsLogin, "tblLogin")
    > > If dsLogin.Tables("tblLogin").Rows.Count = 0 then
    > > lblLoginStatus.Text = "User name and password not found. Please try
    > > again."
    > > Else
    > > Session("UserID") = dsLogin.Tables("tblLogin").Rows(0).Item("UserID")
    > > lblLoginStatus.Text = "Success!"
    > >
    > > End If
    > > End Sub
    > >
    > > --
    > > Sandy
    > >
    > >
    > > "Tu-Thach" wrote:
    > >
    > > > After you authenticate the user, you can call
    > > > FormsAuthentication.RedirectFromLoginPage
    > > >
    > > > This will automagically redirect the user back to the page they want to
    > > > access.
    > > > --
    > > > Tu-Thach
    > > >
    > > >
    > > > "Sandy" wrote:
    > > >
    > > > > Hello -
    > > > >
    > > > > I have two places in my application where someone needs to be logged in. If
    > > > > they are not logged in and I send them to the login page, how do I send them
    > > > > back to the page they originally came from after they log in?
    > > > >
    > > > > Any help will be greatly appreciated!
    > > > > --
    > > > > Sandy
    =?Utf-8?B?U2FuZHk=?=, May 22, 2005
    #7
  8. Thank you, Lucas!
    --
    Sandy


    "Lucas Tam" wrote:

    > "=?Utf-8?B?U2FuZHk=?=" <> wrote in
    > news::
    >
    > > I have two places in my application where someone needs to be logged
    > > in. If they are not logged in and I send them to the login page, how
    > > do I send them back to the page they originally came from after they
    > > log in?

    >
    > ASP.NEt's Forms authentication handles URL redirection for you.
    >
    > --
    > Lucas Tam ()
    > Please delete "REMOVE" from the e-mail address when replying.
    > http://members.ebay.com/aboutme/coolspot18/
    >
    =?Utf-8?B?U2FuZHk=?=, May 22, 2005
    #8
    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. =?Utf-8?B?THluZXJz?=

    Close Form/Webpage and hyperlink back to Original Page

    =?Utf-8?B?THluZXJz?=, Aug 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    684
    Curt_C [MVP]
    Aug 4, 2005
  2. Timasmith
    Replies:
    0
    Views:
    274
    Timasmith
    Nov 18, 2006
  3. Kobu
    Replies:
    3
    Views:
    498
    Kevin Bracey
    Feb 10, 2005
  4. Lance Hoffmeyer
    Replies:
    2
    Views:
    514
    Lance Hoffmeyer
    Jul 26, 2007
  5. Chuck
    Replies:
    0
    Views:
    242
    Chuck
    Jul 5, 2003
Loading...

Share This Page