Has the user logged in??

Last post 01-13-2006 4:12 AM by carebear88. 2 replies.

Sort Posts:

  • Has the user logged in??

    01-12-2006, 7:17 PM
    • Member
      85 point Member
    • carebear88
    • Member since 06-07-2004, 6:48 PM
    • Posts 17

    I have a simple login page that directs the user to an aspx page if they correctly enter their username and password. This page cannot be accessed unless they have logged in, To achieve this I have used a web.config file that denies unauthorised visitors. Here is my web.config file.

    <configuration>
      <location path="Data">
      <system.web>
      <authorization>
      <deny users="?"/>
      </authorization>
      <authentication mode="Forms" />
      </system.web>
      </location>
    </configuration>

    This works well, however i'm wanting to be able to identify the user who logs in. Can anyone help with this?? Here is some code from my login page

    Sub CheckCredentials_Click(s As Object, e As EventArgs)
     If (CheckCredentials(txtUsername.Text, txtPassword.Text) = True) Then
      Formsauthentication.redirectfromloginpage(txtUsername.Text,false)
      lblCheck.Text = "You entered the right credentials!" 
      Response.Redirect("AddData.aspx")
     Else
      lblCheck.Text = "You entered the wrong credentials!"
      End If
    End Sub

    In the AddData.aspx page I'm wanting to be able to say Welcome (txtUsername.Text).

  • Re: Has the user logged in??

    01-13-2006, 2:55 AM
    • Star
      12,063 point Star
    • ranganh
    • Member since 02-11-2004, 11:35 PM
    • India
    • Posts 2,428

    Hi,

    You can simply use User.Identity.Name.  That would give you the logged in user name.

    Thanks.

    regards,
    Harish

    http://geekswithblogs.net/ranganh
  • Re: Has the user logged in??

    01-13-2006, 4:12 AM
    • Member
      85 point Member
    • carebear88
    • Member since 06-07-2004, 6:48 PM
    • Posts 17

    Hey Ranganh, thanks for the reply, i'm not having alot of luck with this if I enter this it will just enter it on the page.

    User.Identity.Name

    I would have thought just the above would do the trick but is there more i need to do runnat a server or something.

Page 1 of 1 (3 items)