public ActionResult Login(LoginViewModel model) { try { if (Session != null) { Session.Clear(); Session.Abandon(); } FormsAuthentication.SignOut(); System.Web.HttpContext.Current.User = new GenericPrincipal(new GenericIdentity(String.Empty), null); ModelState.Clear(); if (ModelState.IsValid) { bool sucsess = model.validate(model); if (sucsess) { Session["Credencial"] = model; SetUserAuthCookie(); return RedirectToAction("index", "admin"); } else { ModelState.AddModelError("EmailAddress", "Invalid Email Address or Password."); } } else { ModelState.AddModelError("", "Please enter a Email Address and Password."); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } return View(model); }