public JsonResult LogOn(string name, string pwd, string vlidateCode, string returnUrl) { if (Session["ValidateCode"].ToString() != vlidateCode) { var jsonError = new { isSuccess = false, url = "/", message = "ValidateCode is not same!" }; return(Json(jsonError)); } var user = appUserService.FetchLogonUser(name, pwd); if (user != null && user.Count > 0) { FormsAuthentication.SetAuthCookie(name, false); var json = new { isSuccess = true, url = "../home" }; return(Json(json)); } else { var jsonNoUser = new { isSuccess = false, url = "/", message = "Your login account is not right!" }; return(Json(jsonNoUser)); } //return RedirectToAction("Show", "Message", new { Area = "", Time = DateTime.Now.ToString("yyyyMMddHHmmss") }); //if (ModelState.IsValid) //{ // try // { // var user = appUserService.FetchLogonUser(name, pwd); // if (user != null) // { // user.Authenticate(model.Password); // FormsAuthentication.SetAuthCookie(user.LogOnName, model.RememberMe); // SessionWrapper.LogOnUser = new LogOnUser() { Id = user.Id, LogOnName = user.LogOnName, Name = user.FullName }; // AddAppPrompt(String.Format(WebMessage.Auth_LogOn_Welcome, user.FullName), AppPromptType.Success); // return RedirectViaMessage(returnUrl); // } // else // { // throw new InvalidOperationException(WebMessage.Auth_LogOn_InvalidLogOnName); // } // } // catch (Exception e) // { // Logger.Log(e); // ModelState.AddModelError(String.Empty, e.Message); // } //} // If we got this far, something failed, redisplay form //return View(model); }