StackTrace StackTrace - 1 year ago 73 Question

How do I get the currently loggedin Windows account from an ASP.NET page?

I have an ASP.NET 3.5 application that uses ASP.NET forms authentication. I want to be able to get the Windows user name currently logged into the computer (NOT logged into the ASP.NET application, but into Windows) when data is edited in a page.

If I use

, I get the user name logged into the ASP.NET application, but I need the Windows account name.


Also, it only works when I run the website from Visual Studio, but after deploying to IIS it returns NT AUTHORITY\SYSTEM.

Answer Source

You have to set authentication mode to Windows in your configuration & also disable anonymous users in authorization tag.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download