2009-02-26 83 views
2

嗨我想知道什麼是強制用戶登錄到.net網站時登錄的最佳方式。我已經設置了會員功能,我想知道確保無論用戶到達哪個地址都必須先進行身份驗證,然後才能進入他們要求的頁面。任何資源都會很好,謝謝。登錄會員.NET

回答

13

阿爾特Web.config在應用程序根目錄爲:

<authentication mode="forms"> 
    <forms loginUrl="Login.aspx" defaultUrl="/" /> 
</authentication> 
<authorization> 
    <deny users="?" /> 
    <allow users="*" /> 
</authorization> 

旁註:很顯然,ASP.NET只能保護那些流傳下來到ASP.NET引擎的請求。默認情況下,它無法在IIS經典模式下強制執行靜態資源的安全性。在這種情況下,爲了控制對靜態資源的訪問,它們應該顯式映射到IIS配置中的ASP.NET ISAPI DLL。

更多關於這裏授權信息:ASP.NET Authorization

4

Forms Authentication explained

下面是一個web.config樣本

<forms loginUrl="Login.aspx" 
     protection="All" 
     timeout="30" 
     name=".ASPXAUTH" 
     path="/" 
     requireSSL="false" 
     slidingExpiration="true" 
     defaultUrl="default.aspx" 
     cookieless="UseDeviceProfile" 
     enableCrossAppRedirects="false" />