public ActionResult Enter() { var viewModel = new EnterModel(); if (Request.IsAjaxRequest()) { return Json(viewModel, JsonRequestBehavior.AllowGet); } return RedirectToAction("Index", "Home"); }
public ActionResult Enter(EnterModel model) { if (ModelState.IsValid) { if (lgHelper.ValidateUser(model.Login, model.Password)) { dbHelper.Configure(); CurrentUser = DbHelper.FindContacts(model.Login)[0].User; var cookie = new HttpCookie("ID") {Value = model.Login, Expires = DateTime.Now.AddMonths(3)}; System.Web.HttpContext.Current.Response.SetCookie(cookie); if (model.Login == "Admin") { CheckInputAdmin = true; } return Json(new { state = "success", parameters = new { url = Url.Action("Index", "Home") } }); } } return Json(new {state = "error", parameters = new {message = ValidationStrings.IncorrectEnter}}, JsonRequestBehavior.AllowGet); }