Introduction
Here I will explain how can we get username and userid of currently logged user in asp.net membership.
Description
I am working on application by using login control in asp.net at that time I got requirement like getting username and user id of logged in user for that I have written code like this to get logged in user username and userid in asp.net membership.
MembershipUser currentUser = Membership.GetUser(); //Get Username of Currently logged in user string username = currentUser.UserName; //Get UserId of Currently logged in user string UserId = currentUser.ProviderUserKey.ToString(); |
By using above code we can get currently logged user in login control
Here i written much code like from Membership i am getting currently logged in username no need to use MembershipUser event to get currently logged in user we have another simple way to get currently logged in username you just define like this in your page
Here i written much code like from Membership i am getting currently logged in username no need to use MembershipUser event to get currently logged in user we have another simple way to get currently logged in username you just define like this in your page
string userName = Page.User.Identity.Name; |
0 comments :
Post a Comment