我的 Web 应用程序使用 Windows 身份验证。所有其他身份验证方法均被禁用。
一开始就有效;User.Identity.Name 返回“MYDOMAIN\myuser”。但是,如果我等待 131 秒(是的,我计时了,尽管我不确定它总是需要那么长时间)并重新加载页面,User.Identity.IsAuthenticated = false 和 User.Identity.Name = ""。在这一点上,我可以重新加载页面,它再次工作,另外 131 秒不活动。
web.config 的相关部分:
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
<identity impersonate="false" />
...
<security>
<authentication>
<windowsAuthentication enabled="true" />
<anonymousAuthentication enabled="false" />
</authentication>
</security>
更多信息,可能相关:
我的解决方案部署到两个不同的 IIS 应用程序。第一个是内部用户;它只是使用 Windows 身份验证。第二个是针对外部用户的;它使用匿名身份验证(仅在根文件夹中)和表单身份验证。我只是对内部站点有问题。