public ActionResult Login(LoginModel model, string returnUrl) { if (!ModelState.IsValid) { return View("login", model); } // check login credentials if (GlobalConfig.Get().Username.Equals(model.Username, StringComparison.OrdinalIgnoreCase) && GlobalConfig.Get().Password.Equals(model.Password)) { FormsAuthentication.SetAuthCookie(model.Username, false); } else { ModelState.AddModelError("failed", "Benutzername oder Passwort falsch."); return View("login", model); } // return to target page. if (Url.IsLocalUrl(returnUrl)) { return Redirect(returnUrl); } else { return RedirectToAction("index", "home"); } }
public ActionResult Login() { var login = new LoginModel(); return View(login); }