I want to get the current authenticated username in my razor view page, so I use
if (User.Identity.IsAuthenticated)
{
<p>Name is @User.Identity.Name</p>
}
but @User.Identity.Name always shows the id of the user.
Try this (MVC):
@{ var userName = System.Web.HttpContext.Current.User.Identity.Name; }
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