asp.net MVC2.0
VIEW:
$.ajax({
type: "post",
async: false,
cache: false,
url: "DoLogin.aspx",
data: { Uname: $("#txt_LoginName").val(), Upwd: $("#txt_PassWord").val(), vliCode: $("#SecurityCode").val() },
success: function(Data) {
if (Data != "") {
if (Data == "00") {//登录成功
window.location.href = "/UserLogin/index.aspx";
}
else if (Data == "11")//用户名或密码错误
alert("用户名或密码错误!");
else if (Data == "0011") {//已经登录
window.location.href = "/UserLogin/index.aspx";
}
else
alert("验证码错误!");
}
}
});Controller:
public string DoLogin(string Uname, string Upwd, string vliCode)
{
string msg = string.Empty;
if (User.Identity.IsAuthenticated)
return "0011";
if (!string.IsNullOrEmpty(vliCode))
{
string vCode = Session["ValidateCode"] + "";
if (vCode == vliCode)
{
string encode = ConfigurationManager.AppSettings["ThickLock"].ToString();
encode = encode + Upwd;
Upwd = TMB.Common.Encrypt.AES.Encode(Upwd, encode);
var hct = Hcoacct.LoginByName(Uname, Upwd);(Hcoacct为实体类,这个方法执行完页面就被加载了。比较费解!!求解释)
if (hct != null)
{
UserVerification uver = new UserVerification();
//添加登录用户身份验证
uver.Authorization(Uname);
return "00";//登录成功 }
else
{
return "11";//用户名或密码错误!
}
}
else
{
return "22";//验证码错误!
}
}
return msg;
}
VIEW:
$.ajax({
type: "post",
async: false,
cache: false,
url: "DoLogin.aspx",
data: { Uname: $("#txt_LoginName").val(), Upwd: $("#txt_PassWord").val(), vliCode: $("#SecurityCode").val() },
success: function(Data) {
if (Data != "") {
if (Data == "00") {//登录成功
window.location.href = "/UserLogin/index.aspx";
}
else if (Data == "11")//用户名或密码错误
alert("用户名或密码错误!");
else if (Data == "0011") {//已经登录
window.location.href = "/UserLogin/index.aspx";
}
else
alert("验证码错误!");
}
}
});Controller:
public string DoLogin(string Uname, string Upwd, string vliCode)
{
string msg = string.Empty;
if (User.Identity.IsAuthenticated)
return "0011";
if (!string.IsNullOrEmpty(vliCode))
{
string vCode = Session["ValidateCode"] + "";
if (vCode == vliCode)
{
string encode = ConfigurationManager.AppSettings["ThickLock"].ToString();
encode = encode + Upwd;
Upwd = TMB.Common.Encrypt.AES.Encode(Upwd, encode);
var hct = Hcoacct.LoginByName(Uname, Upwd);(Hcoacct为实体类,这个方法执行完页面就被加载了。比较费解!!求解释)
if (hct != null)
{
UserVerification uver = new UserVerification();
//添加登录用户身份验证
uver.Authorization(Uname);
return "00";//登录成功 }
else
{
return "11";//用户名或密码错误!
}
}
else
{
return "22";//验证码错误!
}
}
return msg;
}
Hcoacct.LoginByName(Uname, Upwd);//Hcoacct为实体类,这个方法执行完页面就被加载了。比较费解!!求解释)方法执行完就被加载不知道是什么意思?
不是一个(类或对象)根据传进来的用户名和密码构造一个用户对象吗,下面根据此用户对象是否为空来判断登录结果吗