【问题标题】:Cant get HttpContext.Current.User.Identity to return values无法让 HttpContext.Current.User.Identity 返回值
【发布时间】:2014-05-09 11:23:15
【问题描述】:

此项目使用 System.Security.Principal.WindowsIdentity 进行身份验证

我看过这个: Can't get HttpContext.Current.User.Identity to work in my WebMatrix project

        IIdentity WinId = HttpContext.Current.User.Identity;//returns no data
        WindowsIdentity wi = (WindowsIdentity)WinId;

我在我的 Web.config 中禁用了匿名

http://forums.asp.net/t/1901573.aspx?System+web+HttpContext+Current+User+Identity+Name+returns+Empty+string

  <authorization>
    <deny users="?" />
  </authorization> 

奇怪的是我有另一个项目,它使用相同的代码并且具有相同的 .config 但可以工作,

【问题讨论】:

标签: c# asp.net httpcontext windows-identity


【解决方案1】:

你有没有在你的网络配置中写过这个??

<authentication mode="Windows"/>

请看看这个

System.Web.HttpContext.Current.User.Identity.Name Vs System.Environment.UserName in ASP.NET

【讨论】:

  • 是的,我有,我不能使用 System.Environment.UserName,因为这是一个 Intranet 应用程序
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-10-02
  • 1970-01-01
  • 1970-01-01
  • 2013-10-05
  • 1970-01-01
  • 2018-10-04
  • 2017-12-07
相关资源
最近更新 更多