Get username by user ID aspnet.Identity in asp.net mvc
18,049
Solution 1
You need get user user information from user manager:
string username = HttpContext.Current.GetOwinContext()
.GetUserManager<ApplicationUserManager>().FindById(ID).UserName;
Solution 2
you can get the username of any MembershipUser using the below code:
string userName = Membership.GetUser(userId).UserName;
userId
is the Guid primary key of the user.
Author by
Chathz
Updated on June 29, 2022Comments
-
Chathz almost 2 years
With the least effort how to find out Username in Asp.Net MVC
try following code and seems like not working
string Username = User.Identity.GetUserName(Id);