[英]Not able to get the Windows User Name using 'User.Identity.Name' in ASP.NET
I am trying to use 'MsgBox(User.Identity.Name)' to show the Current Windows User in a MessageBox. 我正在尝试使用“ MsgBox(User.Identity.Name)”在MessageBox中显示当前Windows用户。 The MessageBox that appears shows "App_Web_1gu0lxe5" as the Title and Message is Empty.
出现的消息框显示“ App_Web_1gu0lxe5”,因为标题和消息为空。 In other words I am not able to get the Current Windows User in the Output.
换句话说,我无法在输出中获得“当前Windows用户”。
I am using Windows 8.1 Enterprise, 64-bit Operating System, Microsoft Visual Studio 2012, Visual Basic is the Programming Language and I am trying to develop a Web Application. 我正在使用Windows 8.1企业版,64位操作系统,Microsoft Visual Studio 2012,Visual Basic是编程语言,并且我正在尝试开发Web应用程序。
When I am running the same code on a Machine running "Windows 7 Enterprise, Service Pack 1, 64-bit Operating System" the code produces the desired result. 当我在运行“ Windows 7 Enterprise,Service Pack 1,64位操作系统”的计算机上运行相同的代码时,该代码将产生所需的结果。
Any Idea what could be the cause of the Problem? 任何想法可能是问题的原因吗?
You probably had Anonymous Authentication on as well as Windows Authentication. 您可能同时具有匿名身份验证和Windows身份验证。 Turn off Anonymous off.
关闭匿名关闭。
So, 所以,
<system.web>
<authentication mode="Windows" />
</system.web>
In IIS config for the app, look in Authentication tab 在应用程序的IIS配置中,在“身份验证”选项卡中查找
Set Anonymous Authentication to Disabled and Set Windows Authentication to Enabled 将匿名身份验证设置为禁用,并将Windows身份验证设置为启用
This should work and the Identity.UserName should now show up properly. 这应该可以正常工作,并且Identity.UserName现在应该正确显示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.