With the least effort, how to find out a username in Asp.Net MVC
try the following code and it doesn't seem to work
string Username = User.Identity.GetUserName(Id);
You need to get user information from the user:
string username = HttpContext.Current.GetOwinContext() .GetUserManager<ApplicationUserManager>().FindById(ID).UserName;
you can get the username of any member of MembershipUser using the code below:
string userName = Membership.GetUser(userId).UserName;
userId is the main key of the user guid.
userId