Reputation: 31313
With ASP.NET impersonation, can one use Environment.UserName
to determine if impersonation is working? That is if the site is impersonating properly, should Environment.UserName
return my username?
Upvotes: 2
Views: 521
Reputation: 1038710
You should use User.Identity.Name
:
[Authorize]
public ActionResult Foo()
{
// If we got so far it means that the user is authorized to
// execute this action according to our configuration =>
// we can work with his username
string username = User.Identity.Name;
...
}
Upvotes: 2