public ActionResult Login(LoginModel model, string returnUrl) { bool userValid = model.Password == "nrkstudio"; // User found in the database if(userValid) { FormsAuthentication.SetAuthCookie("testcookie", true); if(Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } } // If we got this far, something failed, redisplay form model.IsLoginAttemptWithWrongPassword = true; return RedirectToAction("Index", model); }
public ActionResult Index(LoginModel model) { return View(model); }