How to Find UserId and UserName

Last post 05-17-2008 6:42 AM by lmax25. 2 replies.

Sort Posts:

  • How to Find UserId and UserName

    05-15-2008, 4:55 PM
    • Loading...
    • lmax25
    • Joined on 03-17-2008, 4:32 PM
    • Posts 85

    Hello ! 

    How can I find any time and inside any page the name and the UserId of the logged user ?

    I need this for a query : SELECT [Book], [Author] FROM [Books] WHERE ( UserId,UserName = Logged in User)

    I don't want to use a LoginView because I use a master page and I have one already there.

    I am using Asp.Net 2.0 and forms authentication.

    Thank You !

  • Re: How to Find UserId and UserName

    05-15-2008, 5:12 PM
    Answer
    • Loading...
    • anas
    • Joined on 09-21-2006, 4:31 AM
    • Jerusalem
    • Posts 3,878

    I assume your are working with membership and Forms Authentication ,

     to get the UserId ,

    Dim usr as MembershipUser=Membership.GetUser()

    dim UserID as string =usr.ProviderUserKey.ToString()

    dim UserName as string=usr.UserName

     

    to pass those to Select statement , see this thread :

    http://forums.asp.net/t/1260726.aspx 

     

    Best Regards,

    Anas Ghanem| LogFile
  • Re: How to Find UserId and UserName

    05-17-2008, 6:42 AM
    • Loading...
    • lmax25
    • Joined on 03-17-2008, 4:32 PM
    • Posts 85

    Thank You Very Much for your answer !

Page 1 of 1 (3 items)