Exemple #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string      name     = context.Request["name"];
            string      password = Common.Encryption.MD5encryption(context.Request["pwd"]);
            UserInfoBLL bll      = new UserInfoBLL();

            if (bll.CheckLoginUser(name, password))
            {
                context.Session["LoginName"] = name;
                context.Response.Write("yes");
            }
            else
            {
                context.Response.Write("no");
            }
        }
Exemple #2
0
        //用户名密码校验
        private void CheckUserNameAndPwd()
        {
            string      name     = Request.Form["name"];
            string      password = Encryption.MD5encryption(Request.Form["pwd"]);
            UserInfoBLL bll      = new UserInfoBLL();

            #region Method #1
            //UserInfo user = null;
            //string msg = string.Empty;
            //if (bll.CheckLoginUser(name,password,out user,out msg))
            //{
            //    //Session["LoginUser"] = user;
            //    Session["LoginName"] = user.UserName;
            //    Response.Redirect("Index.aspx");
            //}
            //else
            //{
            //    ErrorMsg = msg;
            //}

            #endregion
            #region Method #2
            //判断用户名密码是否匹配
            if (bll.CheckLoginUser(name, password))
            {
                if (!string.IsNullOrEmpty(Request.Form["autoLogin"]))
                {
                    HttpCookie cookie1 = new HttpCookie("ckName", name);
                    cookie1.Expires = DateTime.Now.AddDays(3);
                    Response.Cookies.Add(cookie1);
                    HttpCookie cookie2 = new HttpCookie("ckPwd", password);
                    cookie2.Expires = DateTime.Now.AddDays(3);
                    Response.Cookies.Add(cookie2);
                }
                Session["LoginName"] = name;
                Response.Redirect("Index.aspx");
            }
            else
            {
                ErrorMsg = "Invalid user name or pswd";
            }

            #endregion
        }