【发布时间】:2014-07-26 13:04:54
【问题描述】:
我正在开发 ASP.Net MVC-4 应用程序。我必须实现 Windows 身份验证。 我已在 web.config 文件中将身份验证模式设置为“Windows”,如下所示。
<system.web>
<authentication mode="Windows" />
</system.web>
在控制器中,我尝试获取用户名,如下所示。
string userName = User.Identity.Name;
但每次我得到空值。 请让我知道任何建议。 提前致谢。
【问题讨论】:
-
你试过
HttpContext.Current.User.Identity.Name -
是的,我也尝试使用“HttpContext.User.Identity.Name”。但没有价值。
-
您是否在 IIS 中启用了 Windows 身份验证?
-
请同时在 IIS 中设置窗口身份验证。 grekai.wordpress.com/2011/03/31/…
-
您需要在您的 IIS 中启用 windows 身份验证并禁用匿名身份验证
标签: c# asp.net asp.net-mvc-4