HttpContext.Current.User.Identity.Name returns blank

asp.net, windows-identity

Solution

You probably had Anonymous Authentication on as well as Windows Authentication. Turn off Anonymous off.

So,

<system.web>
    <authentication mode="Windows" />
</system.web>

In IIS config for the app, look in Authentication tab

Set **Anonymous Authentication** to **Disabled** and
Set **Windows Authentication** to **Enabled**

This should work and the Identity.UserName should now show up properly.

Problem

I am using HttpContext.Current.User.Identity.Name to get the user name when the web application is in use. During development I was using my local iis, with integrated windows authentication enabled and anonymous access enabled and disabled, and I was able to get the username. Now, when I publish the web application, it comes back blank. The setup on the published server is the same, and I have tried using Page.User.Identity.Name, which also returned blank. Does anyone know why this is and how to fix it?

Original source