2013-06-13 123 views
1

我想玩WindowsAuthentication,但看起来在第一个障碍中倒下了。使用Windows身份验证的ASP.Net WebForms

所以我创建了一个空ASP.Net Web表单应用程序,并修改了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为false)。

我的期望是看到我的Windows帐户名称返回例如mydomain\rob

我在哪里出错了?

+1

使用IIS或ASP.NET开发服务器? – sq33G

+1

我正在使用IIS Express(来自VS)。切换到使用ASP.Net开发服务器,它工作正如我所料... – glosrob

回答

2

在IIS中,启用匿名身份验证时Windows身份验证不起作用。

相关问题