【问题标题】:ASP.Net WebForms using Windows Authentication使用 Windows 身份验证的 ASP.Net WebForms
【发布时间】:2013-06-13 10:00:01
【问题描述】:

我想尝试一下 WindowsAuthentication,但似乎在第一个障碍时就失败了。

所以我创建了一个空的 ASP.Net Webforms 应用程序并修改了 web.config:

<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0"/>
        <httpRuntime/>

        <authentication mode="Windows" />
        <identity impersonate="true"/>
    </system.web>
</configuration>

启动应用程序并在页面加载时检查以下值:

HttpContext.Current.User.Identity.Name

但它返回一个空字符串(并且还表明HttpContext.Current.User.Identity.IsAuthenticated 为假)。

我的期望是看到我的 Windows 帐户名返回,例如mydomain\rob

我哪里错了?

【问题讨论】:

  • 使用 IIS 或 ASP.NET 开发服务器?
  • 我使用的是 IIS Express(来自 VS)。切换到使用 ASP.Net 开发服务器,它按我的预期工作......

标签: asp.net webforms windows-authentication


【解决方案1】:

在 IIS 中,启用匿名身份验证时 Windows 身份验证将不起作用。

【讨论】:

    猜你喜欢
    • 2017-04-17
    • 2011-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-27
    • 2016-08-25
    相关资源
    最近更新 更多