public ActionResult Login(LoginModel loginModel) { if (ModelState.IsValid) { try { var user = LoginMapper.GetMVCEntity(login.Login(loginModel.MailOrLogin, loginModel.Password)); FormsAuthentication.SetAuthCookie(user.Login, true); return(RedirectToRoute("Home")); } catch (Exception e) { ModelState.AddModelError(e.Message, e.Message); } } string errorMessage = GetModelStateErrors(ModelState); if (Request.IsAjaxRequest()) { return(Json(new { Result = errorMessage })); } return(View()); }
public IActionResult Login() { var model = new LoginModel(); return(View(model)); }