How to find out the name of currently logged in user in ASP.NET?
.net, asp.net, c#
Solution
You have to set the authentication in IIS to Windows Authentication (and probably disable all others):
Go to:
- Website
- IIS - Authentication
- Edit according your wishes
Problem
I have an ASP.NET application, which runs on machine 1. When a user access that page from machine 2, I want to find out the user name, under which he or she is logged in on machine 2. I tried to use - `Request.LogonUserIdentity.Name` - `Page.User.Identity.Name` - `((WindowsIdentity)HttpContext.Current.User.Identity).Name` - `((WindowsIdentity)HttpContext.Current.User.Identity).User` - `Request.LogonUserIdentity.User` but it doesn't work. `Request.LogonUserIdentity.Name` returns `NT AUTHORITY\IUSR`, `Request.LogonUserIdentity.User` - `S-1-5-17`, all others - empty strings. `NT AUTHORITY\IUSR` is the user on the machine, on which the web application runs, not the user on the client machine. In `web.config` I disabled impersonation using ``` <authentication mode="Windows"/> <identity impersonate="false"/> ``` What can I do in order to get the user name of the user, who accesses the web page?