Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the ID of the current logged in user?

I'm working on a sample project built from the ASP.NET Web Application template (web forms, not MVC). After a user logs in, I want to grab the user's ID and store it in a session variable so I can pass it between pages. How do I get the user's ID from the ASP.NET membership provider? By user's ID, I'm referring to the GUID in the membership database. Is there a method to get the user's ID?

I'm using the default database schema and have it deployed to my server.

Thanks!

like image 683
DenaliHardtail Avatar asked Dec 06 '22 22:12

DenaliHardtail


1 Answers

Try this:

MembershipUser membershipUser = Membership.GetUser();
string UserID = membershipUser.ProviderUserKey.ToString();
like image 75
BrandonZeider Avatar answered Dec 22 '22 06:12

BrandonZeider