在 MVC2 中使用 Windows 身份验证时获取 Active Directory 用户名

发布于 2024-11-29 02:24:23 字数 126 浏览 5 评论 0原文

在使用 Windows 身份验证对 MVC2 网站上的用户进行身份验证后,我试图在控制器中获取 Windows 用户名。我怎样才能做到这一点?我知道您可以使用 Page.User.Identity.Name 从视图端获取它?那么控制器呢?

I am trying to get the windows username in my controller after using windows authentication to authenticate user on my MVC2 website. How can I do that? I know you can use Page.User.Identity.Name to get it from the view side? What about the controller though.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独孤求败 2024-12-06 02:24:23

您可以在控制器中访问它,如下所示:

this.HttpContext.User.Identity.Name

You can access it in a Controller like so:

this.HttpContext.User.Identity.Name
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文