コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: YhController.cs プロジェクト: xiaoheshang/mvcdemo
 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"));
     }
 }