【问题标题】:Why do Chrome and Internet Explorer return different values for HttpContext LogonUserIdentity when debugging?为什么 Chrome 和 Internet Explorer 在调试时返回不同的 HttpContext LogonUserIdentity 值?
【发布时间】:2017-07-01 08:11:09
【问题描述】:

我有一个在 IIS 上使用 Windows 身份验证的应用程序,我使用

检索用户名
WindowsIdentity identity = HttpContext.Current.Request.LogonUserIdentity;

在我的授权码中。出于安全原因,我登录的 Windows 帐户没有本地管理员权限,因此我必须使用不同的登录凭据以管理员身份运行 Visual Studios。

当我使用 Google Chrome 调试时,上面的代码将 identity.Name 属性设置为登录到我的计算机的帐户的用户名,这是我的预期,但是当我使用 Internet Explorer 调试时,上面的代码设置了身份。名称为我登录以以管理员身份运行 Visual Studio 的本地管理员帐户的用户名。

是什么原因导致同一代码返回的值因我使用的浏览器而异?

【问题讨论】:

    标签: c# google-chrome internet-explorer-11 visual-studio-2017 windows-authentication


    【解决方案1】:

    您是否从 Visual Studio 启用 Windows 身份验证/禁用匿名身份验证?以下链接显示了不同设置的结果。

    https://richhewlett.com/2011/02/15/getting-a-users-username-in-asp-net/

    【讨论】:

    • 我启用了 Windows 身份验证并禁用了来自 IIS 的匿名身份验证。无论我在那篇文章中使用哪种方法,结果都是一样的,在 Internet Explorer 中返回 ladm 帐户,在 Chrome 中返回全局帐户。 Visual Studio 中是否有我还需要为项目/解决方案更改为 Windows 身份验证的地方?我似乎无法在属性中找到该设置。
    • (VS 2015 => View Menu => Properties Windows) / F4 ,点击项目,应该可以看到窗口了。在开发服务器下,您可以选择匿名身份验证和 Windows 身份验证的下拉菜单。
    猜你喜欢
    • 1970-01-01
    • 2016-07-01
    • 2015-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-28
    • 1970-01-01
    相关资源
    最近更新 更多