【发布时间】:2013-06-13 10:00:01
【问题描述】:
我想尝试一下 WindowsAuthentication,但似乎在第一个障碍时就失败了。
所以我创建了一个空的 ASP.Net Webforms 应用程序并修改了 web.config:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<httpRuntime/>
<authentication mode="Windows" />
<identity impersonate="true"/>
</system.web>
</configuration>
启动应用程序并在页面加载时检查以下值:
HttpContext.Current.User.Identity.Name
但它返回一个空字符串(并且还表明HttpContext.Current.User.Identity.IsAuthenticated 为假)。
我的期望是看到我的 Windows 帐户名返回,例如mydomain\rob
我哪里错了?
【问题讨论】:
-
使用 IIS 或 ASP.NET 开发服务器?
-
我使用的是 IIS Express(来自 VS)。切换到使用 ASP.Net 开发服务器,它按我的预期工作......
标签: asp.net webforms windows-authentication