How to get current Windows Login Name in C# Web APP?

c#

Solution

Try `Page.User.Identity.Name`. This should be what you're looking for. This property is derived from `HttpContext` and represents the logged in user security information for the current HTTP request.

If the result is null, then I would suspect that the IIS settings is not configured properly. Try the advice in the following links:

http://forums.asp.net/t/1689878.aspx/1 HttpContext.Current.User.Identity.Name is Empty

Problem

How can I get the user name of Windows Login? I used these methods: - Environment.UserName - WindowsIdentity.GetCurrent().Name; But, when I PUT this inside IIS server, it takes the name of the server, not my machine.

Original source

Related problems