public ActionResult Index() { // Create object of model call for call properties and set value var vSessionValue = new SessionAspDotNetMvc(); try { // check existing value into session if ((Object)Session["SessionUserID"] != null) { // assign value into properties vSessionValue.sSessionValue = "Welcome " + Session["SessionUserID"].ToString(); } else { // if session expired than set custom message vSessionValue.sSessionValue = "Session Expired"; } } catch { } // return value to view return(View(vSessionValue)); //return View(); }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl, SessionAspDotNetMvc data) { Session["SessionUserID"] = data.sUserID; if (!ModelState.IsValid) { return(View(model)); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false); switch (result) { case SignInStatus.Success: return(RedirectToLocal(returnUrl)); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe })); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } }