Pirate X Pirate X - 8 months ago 45
ASP.NET (C#) Question

IIS not picking up Windows User

I made a web application which displays Windows User Name on top right.
If I open the webapp on

I get correct Windows User.
Like this -

enter image description here

But if I open
I get IIS AppPool User -

enter image description here

Here db is the directory which has my app.

I have no idea why is this happening. I want the localhost to show the correct Username as well.

My IIS tree, here DB(1) is my webapp -

enter image description here

My C# code which picks Windows Identity -

<li><% string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;%>
<a><%= userName %></a>


You need to setup the site in IIS for Windows Authentication only and turn off Anonymous.

Go into IIS for you site then under Features View.

Then under the IIS category > Authentication > Set Windows Authentication to Enabled and all others (Anonymous....others) to Disabled.

Instead of...