public ActionResult Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { if (OperateContext.Current.Login(model)) { return RedirectToLocal(returnUrl); } else { ModelState.AddModelError("", "用户名或密码错误."); } } //跳转到原来的地址 ViewBag.ReturnUrl = returnUrl; // 如果我们进行到这一步时某个地方出错,则重新显示表单 return View(model); }
/// <summary> /// 会员登录方法 /// </summary> /// <param name="usrPara"></param> public bool Login(LoginViewModel model) { //到业务成查询 var user = ServiceSession.IUserService.Login(model.UserName, Util.Security.UEncypt.MD5(model.Password)); if (user != null) { //保存用户数据(Session or Cookie) SetUserToSessionAndCookies(user, true); return true; } return false; }
public ActionResult LoginDialog(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { if (OperateContext.Current.Login(model)) { return JsonMsgOk("登陆成功"); } } // 如果我们进行到这一步时某个地方出错,则重新显示表单 return JsonMsgNoOk("用户名或密码错误"); }