protected void IBlogin_Click(object sender, ImageClickEventArgs e) { string ip = Page.Request.UserHostAddress; DateTime logintime = DateTime.Now; string userid = JScript.SafeRequest(txtUserName.Text); if (Session["CheckCode"] != null) //检查验证码是否超时 { if (txtCodeValidate.Text.ToString() == Session["CheckCode"].ToString()) //检查用户输入的验证码是否正确 { bool checkpass = user.UserLogin(userid, JScript.SafeRequest(txtPassWord.Text)); if (checkpass) { user.AddLoginLog(userid, ip, logintime, "成功"); Response.Redirect("Manage/Default.aspx"); } else { msg.Text = "登陆失败!"; txtPassWord.Text = ""; txtUserName.Text = ""; txtCodeValidate.Text = ""; user.AddLoginLog(userid, ip, logintime, "失败"); } } else { msg.Text = "验证码错误!"; } } else { user.AddLoginLog(userid, ip, logintime, "失败"); Response.Redirect("error.htm"); } }