这可能是重复问题,但我没有从其他帖子中找到任何解决方案。HttpContext.Current.User.Identity.Name每次都是空的
我正在使用Windows身份验证,当我在本地系统上构建应用程序时,它的工作正常,但是当我在IIS上部署应用程序时,HttpContext.Current.User.Identity.Name返回null。我已禁用身份验证设置以外的Windows身份验证。
var strUserName = HttpContext.Current.User.Identity.Name == "" ? System.Security.Principal.WindowsIdentity.GetCurrent().Name : HttpContext.Current.User.Identity.Name;
我得到strUserName为空。
<authentication mode="Windows">
</authentication>
<identity impersonate="true"/>
我试图划分线和编写代码来检查究竟是什么returing ...
HttpContext.Current.User.Identity.Name is returning null
System.Security.Principal.WindowsIdentity.GetCurrent().Name is returning NT AUTHORITY\IUSR when impersonate is true
System.Security.Principal.WindowsIdentity.GetCurrent().Name is returning IIS APPPOOL\ApplicationPoolName when impersonate is false
以下几个环节我已经检查
User.Identity.Name with windows authentication
我想向您推荐[编辑]您的问题,并添加您发现的其他类似问题,并尽量避免将您的问题标记为重复。 – kayess
我相信第二个''标签会覆盖上面例子中的第一个,所以'mode = Windows'不会被拾取。你可以尝试合并两个配置项目吗? –
您是指服务/ WCF? –