cache:
false
,
async:
true
,
type: 'post',
success:
function
(data) {
if
(data == "OK") {
window.location.href = "/Home/Index";
}
else
{
alert(data);
window.location.href = "/Login/Index";
}
}
});
});
}
用户登录的后台控制器方法如下所示:
///
<summary>
///
对用户登录的操作进行验证
///
</summary>
///
<param name="username">
用户账号
</param>
///
<param name="password">
用户密码
</param>
///
<param name="code">
验证码
</param>
///
<returns></returns>
public
ActionResult CheckUser(
string
username,
string
password,
string
code)
{
string
result =
""
;
bool
codeValidated =
true
;
if
(
this
.TempData[
"ValidateCode"
] !=
null
)
{
codeValidated = (
this
.TempData[
"ValidateCode"
].ToString() == code);
}
if
(
string
.IsNullOrEmpty(username))
{
result =
"用户名不能为空"
;
}
else
if
(!codeValidated)
{
result =
"验证码输入有误"
;