您可以授權您的用戶如何您想要的。 FormAuthentication用於設置會話身份和身份驗證Cookie,允許用戶保持登錄狀態,直到他們註銷或會話過期。您不需要使用成員資格提供程序來使用FormsAuthentication。這聽起來像你只是複製這個功能。
...do your authentication against your DB or Active Directory
if (Request.QueryString["ReturnUrl"] != null)
{
FormsAuthentication.RedirectFromLoginPage(userName.Text, false);
}
else
{
FormsAuthentication.SetAuthCookie(userName.Text, false);
}
然後,你需要設置在web.config
<system.web>
<authentication mode="Forms">
<forms loginUrl="Login.aspx"
protection="All"
timeout="30"
name="my-auth-cookie"
path="/"
requireSSL="false"
slidingExpiration="true"
defaultUrl="default.aspx" />
</authentication>
</system.web>
你得到做自己的授權和沒有落實餅乾基礎設施的所有優點,使用它。請注意,由於您的網站只需在編輯時授權,您需要設置權限,以便每個人都可以閱讀所有頁面並實施自己的邏輯,以便在編輯時將其重定向到登錄頁面。
更多信息here。
所以通過使用窗體auth,asp.net管道處理讀取cookie等,然後爲當前線程設置IDENTITY實例?其次,我也不能使用RedirectFromLoginPage,因爲我在做AJAX登錄:)(muhaha!)。最後,對於該網站,IIS7是否需要具有窗體身份驗證開啓? – 2008-11-15 06:03:18