问题描述
我的Web应用程序使用Windows身份验证。其他所有身份验证方法都被禁用。
My web app uses Windows authentication. All other authentication methods are disabled.
它工作在第一; User.Identity.Name返回MYDOMAIN \\ myuser的。不过,如果我等待131秒(是的,我计时了,虽然我不知道它总是带这么久),并重新加载页面,User.Identity.IsAuthenticated =虚假和User.Identity.Name =。在这一点上我可以重新载入页面并再次将其工作的,不活动的另一个131秒。
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.
web.config中的相关部分:
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:
我的解决方案部署到两个不同的IIS应用程序。第一个是内部用户;它只是使用Windows身份验证。第二个是用于外部用户;它使用匿名身份验证(仅在根文件夹)和窗体身份验证。我只具有内部站点的问题。
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.
推荐答案
下的帐户文件夹的允许匿名身份验证(我贴我的问题之一是主要的web.config)web.config文件。不知道这是怎么发生的,但删除它解决了这一问题。
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.
这篇关于User.Identity.Name空白有时与Windows身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!