Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
current.user.identity.name间歇性为空_Identity_Httpcontext - Fatal编程技术网

current.user.identity.name间歇性为空

current.user.identity.name间歇性为空,identity,httpcontext,Identity,Httpcontext,我正在使用VS2008开发asp.net web应用程序。我正在使用Windows身份验证。我正在尝试从中捕获当前用户名 HttpContext.Current.User.Identity.Name。它在开发系统上运行得非常好。将代码部署到测试环境(Windows server 2008R2)后,我们注意到 HttpContext.Current.User.Identity.Name间歇性为空。 添加后,我间歇性地收到“401-未经授权:由于凭据无效,访问被拒绝。” IIS 匿名身份验证-已禁用

我正在使用VS2008开发asp.net web应用程序。我正在使用Windows身份验证。我正在尝试从中捕获当前用户名
HttpContext.Current.User.Identity.Name
。它在开发系统上运行得非常好。将代码部署到测试环境(Windows server 2008R2)后,我们注意到
HttpContext.Current.User.Identity.Name
间歇性为空。 添加
后,我间歇性地收到“401-未经授权:由于凭据无效,访问被拒绝。”

IIS
匿名身份验证-已禁用
Windows身份验证–已启用

web.config

<authentication mode="Windows"/>
<authorization>
   <deny users="?"/>
</authorization>


任何帮助都将不胜感激。

以下更改修复了该问题(不是一个失败的请求),但几个小时后问题重新启动。IIS->Sites->My Project->Advanced Settings->ID(在常规部分下)=>将此字段(ID)更改为随机数。我认为这可能是由于应用程序池回收,所以我将应用程序池回收时间间隔设置为0。。。但在一定的时间后,这个问题仍然会重复。