I need to get the server (client pc) OS username (not the machine name) locally. I found the code
Session ["OS_USER"] = Environment.UserName;
but when I host IIS Environment.UserName it captures the IIS username.
I need to get the server (client pc) OS username (not the machine name) locally. I found the code
Session ["OS_USER"] = Environment.UserName;
but when I host IIS Environment.UserName it captures the IIS username.
Take a look at How do I get the current username in .NET using C#?
For Windows following code might work:
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;