gpt4 book ai didi

c# - 无法获取用户的 Windows 登录名?

转载 作者:可可西里 更新时间:2023-11-01 11:21:34 26 4
gpt4 key购买 nike

在我部署在 Intranet 上的 ASP.NET 应用程序中,我在 Web 服务中使用类似这样的东西来获取当前用户的 Windows 登录名:

string user = User.Identity.Name.ToString();

并将以下内容添加到我的 Web.config 文件中:

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

这在我在本地部署我的站点时有效,但在我发布它并使用实际 URL(而不是本地主机)访问它时不起作用。我错过了什么吗?我想获取当前访问我网站的用户的 Windows 登录名。有什么建议吗?

最佳答案

是否在 IIS 中设置了 Windows 身份验证?

您可能需要在 IIS 中设置基本身份验证和 Windows 身份验证的组合才能正常工作。

关于c# - 无法获取用户的 Windows 登录名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7910927/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com