通过给控件login定义 OnAuthenticate="Login1_Authenticate",来执行自定义的登陆验证asp:login id="Login1" runat="server" onauthenticate="Login1_Authenticate" orientation="Horizontal" displayrememberme="false"
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
string username = ((Login)sender).UserName; // 取登录名
string password = ((Login)sender).Password; //取登录密码
if (username == "sl"&password=="1") // 尝试登录
{
e.Authenticated = true; //true登录成功,flase失败
return;
// Response.Redirect("~/index.aspx");
}
else {
return;
//Response.Redirect(Request.QueryString["returnUrl"]);
}
}