public ActionResult Login(FormCollection fc) { ViewModels.Message rsp = new ViewModels.Message(); string username = fc["yhmc"]; string password = fc["yhmm"]; //ViewBa.LgoginState = "登录后:"+username+","+password; DAL.yh yhdal = new DAL.yh(); Model.yh yh = yhdal.GetModelByYhmc(username); if (yh != null && yh.yhmm == Utils.MD5(password)) { FormsAuthentication.SetAuthCookie(username, false); //设置Session ViewModels.YhSession yhSession = new ViewModels.YhSession() { yh = yh, currentXtid = 8 }; Session["yhsession"] = yhSession; //跳转 //return RedirectToAction("Index"); rsp.sno = 1; } else { rsp.sno = 2; rsp.msg = "用户名或密码错误"; } return(Json(rsp, JsonRequestBehavior.DenyGet)); }
public ActionResult ValidateYhmc(string yhmc) { if (!string.IsNullOrEmpty(yhmc)) { try { DAL.yh yhdal = dal as DAL.yh; if (yhdal.Exists(yhmc)) { return(Content("false")); } else { return(Content("true")); } } catch { return(Content("false")); } } else { return(Content("false")); } }