public ActionResult Login() { if (Session["Borrower"] != null) { return(RedirectToAction("Index")); } if (Request.HttpMethod == "POST") { string login = Request.Form["username"]; string password = Settings.SecureString(Request.Form["password"]); Borrower borrower = null; // Let's try to obtain the requested borrower by its login and password try { borrower = Borrower.getByLoginAndPasswd(login, password); } catch { return(View("Error500")); } if (borrower == null) { ViewBag.error = "Please verify your login information."; } else { Session["Borrower"] = borrower; return(RedirectToAction("Index")); } } return(View()); }