更新时间:2023-12-03 19:56:04
您只是忘记了实际登录用户.您要做的只是验证用户凭据,然后进行重定向.因此,请尝试在if语句中添加以下行:
You simply forgot to actually login your user. All you do is validating the users credentials and then do a redirect. So try to add the following line in your if-statement:
protected void LoginButton_Click(object sender, EventArgs e)
{
// Validate the user against the Membership framework user store
if (Membership.ValidateUser(UserName.Text, Password.Text))
{
// Log the user into the site
FormsAuthentication.SetAuthCookie(UserName.Text, true);
// Do the redirect
Response.Redirect("~/Index.aspx");
}
// If we reach here, the user's credentials were invalid
InvalidCredentialsMessage.Visible = true;
}