①JS代码
$.post("/Home/CheckLogin", { "username": $("#username").val(), "password": $("#password").val(), "role": $("#roleSelect").val() }, function (returnString) {
if (returnString == "Error1") {
$("#password").val() = "";
alert("用户名或者密码错误!");
} else if (returnString == "Error2") {
alert("该用户被禁用,请与管理员联系!");
} else if (returnString == "Error3") {
alert("登录异常,请重试!");
}
else {
alert(returnString);
}
});
②C#代码(登录验证成功之后应该跳转用户界面)
if(result == "Success")
{
//登录验证成功,写session,返回用户视图
Session["Role"] = "Student";
Session["UserNum"] = username;
//return RedirectToAction("StudentInfo");
return Redirect("StudentInfo");
}
③结果
