protected void Button1_Click(object sender, EventArgs e) { try { UsersBll userBll = new UsersBll(); UsersModel loginUser = new UsersModel(); loginUser.UserName = TextBox1.Text; loginUser.Pwd = TextBox2.Text; loginUser = userBll.GetModelLogin(loginUser); if (loginUser.UserId != 0) { Session["CurrentUser"] = loginUser; Response.Redirect("./Home.aspx"); } else { Response.Write("<script>alert('用户名或密码错误')</script>"); } } catch { Response.Write("<script>alert('登录异常')</script>"); } finally { } }