public ActionResult CardHolderLogOn(CardHolderLogOnModel model, string returnUrl) { ICardHolderService CardHolderService; String userName; if (ModelState.IsValid) { try { CardHolderService = new CardHolderService(); if (CardHolderService.ValidateUserByEmail(model.UserEmailAddress, model.Password, out userName)) { Log.LoginAttempts(Request.UserHostAddress, model.UserEmailAddress, true); FormsAuthentication.SetAuthCookie(userName, false); Session["ReturnStack"] = new Stack <String>(); return(RedirectToAction("Index", "CardHolder")); } else { Log.LoginAttempts(Request.UserHostAddress, model.UserEmailAddress, false); ModelState.AddModelError("", "The email address or password provided is incorrect."); } } catch (Exception Ex) { ModelState.AddModelError("", Common.StandardExceptionHandler(Ex, "System Set Up", Request.Form)); } } // If we got this far, something failed, redisplay form return(View(model)); }