I have enabled Windows Authentication in my webconfig. Now I want to retrieve the user who Is trying to access the webpage like this:
[AllowAnonymous]
public async Task<ActionResult> Index()
{
try
{
var username2 = System.Web.HttpContext.Current.User.Identity.Name;
}
}
I can't get any user from the Curent.User.Identity.Name
. It's just blank. Why this?
I have also tried to disable Anonymous Authentication, but when I do this, a login dialog Is prompted. I don't want that.
I just want to get the computer user who trying to access the page. Is this possible?
And I'm not looking for Environment.Username
, because that don't work when I deploy to the main server.