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);
You need get user user information from user manager:
string username = HttpContext.Current.GetOwinContext()
.GetUserManager<ApplicationUserManager>().FindById(ID).UserName;
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With