public async Task<ActionResult> Index(Login model, string returnUrl) { if (!ModelState.IsValid) { return View(model); } var user = await UserManager.FindAsync(model.UserId, model.Password); if (user != null) { var authenticationManager = HttpContext.GetOwinContext().Authentication; var userIdentity = UserManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); authenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = false }, userIdentity); return RedirectToLocal(returnUrl); } else { ModelState.AddModelError("", "Invalid username or password."); } return View(model); }
public ActionResult Index() { var vm = new Login(); return View(vm); }