【问题标题】:Windows authentication not working asp.net mvc showing nullWindows 身份验证不起作用 asp.net mvc 显示空
【发布时间】:2017-02-13 20:47:40
【问题描述】:

Web.Config windows 身份验证显示空用户名

我的 WebConfig 身份验证已启用

C# 代码 我试过了

WindowsIdentity.GetCurrent(); // showing null
System.Security.Principal.WindowsIdentity.GetCurrent().Name  // showing null
System.Security.Principal.WindowsIdentity.GetCurrent().Name;// showing null
Request.ServerVariables["LOGON_USER"] // showing null
Request.ServerVariables["REMOTE_USER"] // showing null

【问题讨论】:

  • 您是否使用 IISExpress 托管此内容?您是否关闭了匿名身份验证。
  • 是托管在 IIS 上并且匿名身份验证已关闭

标签: asp.net-mvc c#-4.0 windows-authentication


【解决方案1】:

你有没有输入像这样的Web.Config

<system.web>
   <authentication mode="Windows"/>
</system.web>

【讨论】:

    【解决方案2】:

    在我的例子中,我检查了项目属性窗口。

    匿名身份验证设置为启用,Windows 身份验证设置为禁用。我改变了这些价值观,它帮助了我。

    【讨论】:

    • 在 VS 2019 中打开项目属性窗口:在解决方案资源管理器中选择您的项目并按 F4 或转到查看 -> 属性窗口。
    猜你喜欢
    • 2017-09-24
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 2013-11-28
    • 2022-11-29
    • 1970-01-01
    • 1970-01-01
    • 2023-04-11
    相关资源
    最近更新 更多