WhiteAlligator
WhiteAlligator

Reputation: 53

User.Identity.Name sometimes blank with Windows authentication

My web app uses Windows authentication. All other authentication methods are disabled.

It works at first; User.Identity.Name returns "MYDOMAIN\myuser." However, if I wait 131 seconds (yes, I timed it, though I'm not sure it always takes exactly that long) and reload the page, User.Identity.IsAuthenticated = false and User.Identity.Name = "". At this point I can just reload the page and it works again, for another 131 seconds of inactivity.

Relevant parts of web.config:

<authentication mode="Windows" />
<authorization> 
  <deny users="?" /> 
</authorization>
<identity impersonate="false" />
...
<security>
  <authentication>
    <windowsAuthentication enabled="true" />
    <anonymousAuthentication enabled="false" />
  </authentication>
</security>

More information, possibly relevant:

My solution is deployed to two different IIS applications. The first one is for internal users; it just uses Windows authentication. The second one is for external users; it uses anonymous authentication (in the root folder only) and forms authentication. I'm only having problems with the internal site.

Upvotes: 1

Views: 4230

Answers (1)

WhiteAlligator
WhiteAlligator

Reputation: 53

The web.config file under the Account folder was allowing anonymous authentication (the one I posted with my question is the main web.config). Not sure how that happened, but removing it fixed the problem.

Upvotes: 1

Related Questions