0

I have a small web application which is being currently hosted in a Virtual Machine. The machine has Windows 8 + IIS 7.

As part of the application, I need to get the user name of the people who visit this bloody web application. But every time that I tried to get the current user, I always get the Virtual Machine name.

How can I correctly get the name of the machine, who visit that app. on the Virtual Machine?

Uwe Keim
  • 36,867
  • 50
  • 163
  • 268

2 Answers2

0

On the controller, whether with Windows or Forms Auth, you should be able to get the user via:

this.User.Identity.Name

Or from the HTTP Context:

HttpContext.Current.User.Identity.Name
Brian Mains
  • 49,697
  • 35
  • 139
  • 249
0

If the user is logged in via Active Directory, this should work:

System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent()).Identity.Name;
Drew Kennedy
  • 3,950
  • 4
  • 20
  • 33