2013-09-23 16 views
0

我有這個應用程序,我通過PC用戶登錄。我使用的是這樣的:應用程序不會讀取IIS上的用戶名

public static bool IsAuthenticated() 
{ 
    if (HttpContext.Current.User.Identity.IsAuthenticated) 
    { 
     CurrentUser = Factory.Users.List(item => item.Username.ToLower() == cToLower()).FirstOrDefault(); 
    } 

    return CurrentUser != null; 
} 

注:的.List(),是我創建列出所有的數據庫用戶(在 這種情況下)的方法。

一切工作正常。但是當我在我的IIS上發佈我的網站時,HttpContext.Current.User.Identity.Name不會返回任何內容,根本就沒有用戶。它有什麼問題?任何建議?

+0

你看過這個嗎?這有幫助嗎? http://stackoverflow.com/questions/1056487/httpcontext-current-user-identity-name-is-always-string-empty –

回答

0

您必須啓用IIS Windows Authentication拒絕Annomyous acces。您可以配置您的IIS或更新您的配置文件如下,

<configuration> 
    <system.web> 
    <authentication mode="Windows" /> 
     <authorization> 
      <deny users="?"/> 
      </authorization> 
    </system.web> 
</configuration> 
相關問題