public ActionResult Index(LoginViewModel model) { if (!ModelState.IsValid) { model.Error = "invalid form data"; return AreaView("login/index.cshtml", model); } var service = Ioc.GetService<IUserService>(); if (service.CanLogin(model.Username, model.Password)) { Response.SetAuthCookie(model.Username, model.RememberMe); GetSession().Login(model.Username); return RedirectToAction("index", "home"); } model.Error = "invalid username/password."; return AreaView("login/index.cshtml", model); }
public ActionResult Index() { var model = new LoginViewModel(); return AreaView("login/index.cshtml", model); }