I need to get my logged in Windows user name, from the PC I am using to the server hosting my site.
In my code I have the following line:
var user = WindowsIdentity.GetCurrent().Name;
When I run my project locally it returns what I expect: myComputer\UserAccountName
However, when I deploy my site to my server, it is picking up my servers username: myServer\ServerAccountName
What is the call that I need to make in order to correctly pass down UserAccountName
and not have the ServerAccountName
used instead?
can you not use the following?
User.Identity.Name;