public ActionResult Login(LoginUserModel model, string ReturnUrl) { Users_BLL bll = new Users_BLL(); if (bll.CheckExist(model.UserName, model.PassWord)) { FormsAuthentication.SetAuthCookie(model.UserName, false); //if (((Url.IsLocalUrl(returnUrl) && (returnUrl.Length > 1))&& (returnUrl.StartsWith("/") && !returnUrl.StartsWith("//"))) && !returnUrl.StartsWith(@"/\")) if (!string.IsNullOrEmpty(ReturnUrl)) { return(Redirect(ReturnUrl)); } else { //return RedirectToAction("Index", "Home"); string url = Url.Content(Request.UrlReferrer.AbsoluteUri); string action = url.Substring(url.LastIndexOf("/") + 1, url.Length - url.LastIndexOf("/") - 1); if (action == "Login" || action == "login") { return(RedirectToAction("Index", "Home")); } else { return(Redirect(Url.Content(Request.UrlReferrer.AbsoluteUri))); } } // return RedirectToAction("Index", "Home"); } ModelState.AddModelError("", "用户名或密码错误,请重新输入!"); return(View(model)); }
public ActionResult CheckUser(string UserName) { Users_BLL bll = new Users_BLL(); if (bll.CheckExist(UserName)) { bool result = false; return(Json(result, JsonRequestBehavior.AllowGet)); } else { bool result = true; return(Json(result, JsonRequestBehavior.AllowGet)); } }