1

ASP.NET(2.0)ページにログインコントロールがあります。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がページに表示されます。これをデバッグする方法がわかりません:(

4

1 に答える 1

1

Authenticateイベントも担当しましたか?

<asp:Login id="Login1" runat="server"
            OnAuthenticate="MyOnAuthenticate">


private void MyOnAuthenticate(object sender, AuthenticateEventArgs e)
{
    bool isAuthenticated = false;
    isAuthenticated = YourAuthenticationMethod(Login1.UserName, Login1.Password);

    e.Authenticated = isAuthenticated;
}

private bool YourAuthenticationMethod(string UserName, string pwd)
{
    // Insert code that implements a site-specific custom 
    // authentication method here.             
}

MSDNでのLoginControlのAuthenticatedイベント

于 2009-12-05T18:24:00.740 に答える