1
我的ASP.NET(2.0)頁面上有一個Login控件。我像這樣處理LoggingIn事件:登錄控制 - 錯誤
protected void Login1_LoggingIn(object sender, LoginCancelEventArgs e)
{
// go to database and find this user
if (userTable != null && userTable.Rows.Count > 0)
{
int userID = Convert.ToInt32(userTable.Rows[0]["UserID"]);
HttpCookie userIdCookie = new HttpCookie("UserID", userID.ToString());
Response.AppendCookie(userIdCookie);
}
else
{
e.Cancel = true;
}
}
在數據庫中找到用戶。在這個函數結束時,e.Cancel仍然設置爲false。但之後發生了LoginError。 LoggedIn沒有發生。並且FailureText出現在頁面上。我不知道如何調試這個:(
你可能想通過這篇文章,解釋形式Authetication相當不錯看看 - http://msdn.microsoft.com/en-us/library/aa480476.aspx – 2009-12-05 17:54:00
這有點令人困惑,你可以詳細說明LoginError是什麼? 什麼是LoggedIn和FailureText - 我猜他們正在自我分類但是,解釋得越多,我們就越不用猜測:-) – Steffen 2009-12-05 17:55:41
LoginError是登錄失敗時引發的事件,FailureText是登錄控件的屬性,可用於將登錄失敗的原因轉發給用戶。兩者都與ASP.NET的登錄控制有關 - http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.login.aspx – 2009-12-05 18:01:43