public async Task <ActionResult> Login(LoginModel model) { if (ModelState.IsValid) { SmsServiceUser user = await Usermanager.FindAsync(model.Login, model.Password); if (user == null) { ModelState.AddModelError(String.Empty, "Неверный логин или пароль"); } else { ClaimsIdentity claims = await Usermanager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie); AuthenticationManager.SignOut(); AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = true }, claims); //if (Request.UrlReferrer != null) return Redirect(Request.UrlReferrer.ToString()); return(RedirectToAction("Index", "Home")); } } return(View(model)); }