public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe)) { return RedirectToLocal(returnUrl); } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return View(model); }
public ActionResult Login(LoginModel model, string returnUrl) { Model.User user = UserService.FindBy(p => p.LoginID == model.LoginID && p.Password == model.Password).FirstOrDefault(); if (ModelState.IsValid && user != null) { WebUtility.CurrentUser = user; FormsAuthentication.SetAuthCookie(model.LoginID, model.RememberMe); return RedirectToAction("Create", "Product"); } else { ModelState.AddModelError("", "The login id or password provided is incorrect."); return View(model); } }