asp.net – 为什么HttpContext.Current.User.Identity.Name返回空白

我创建了一个网站.它是一个内部网站.它是一个.NET 4.0站点.我想使用浏览网站的人的HttpContext.Current.User.Identity.Name来获取用户名.没有登录页面,因为它是内部的.我不知道我失踪了什么我的webconfig中需要以下内容
<authentication mode="Windows"></authentication>
<identity impersonate="true"/>
<authorization>
  <allow users="?"/>
</authorization>

和这个:

<system.webServer>
  <validation validateIntegratedModeConfiguration="false" />

解决方法

未认证时,它出现空白.您也可以通过以下方式验证:
HttpContext.Current.User.Identity.IsAuthenticated

检查IIS中的身份验证级别,是否也设置为启用Windows身份验证?

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...