public bool TryLogin(LoginModel loginModel) { var user = UserManager.Find(loginModel.Name, loginModel.Password); if (user != null) { _authenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = false }, UserManager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie)); } return(user != null); }