2013-06-13 54 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身份驗證不起作用。