Пример #1
0
        /// <summary>
        /// 对cookie进行校检
        /// </summary>
        private void CheckCookie()
        {
            if (Request.Cookies["ck1"] != null && Request.Cookies["ck2"] != null)
            {
                string           userName    = Request.Cookies["ck1"].Value;
                string           userPwd     = Request.Cookies["ck2"].Value;
                BLL.User_Service userService = new BLL.User_Service();
                Users_Model      usermodel   = userService.FindUser(userName);
                if (usermodel != null)
                {
                    //判断用户数据库中存储的密码是否与cookie中存储的密码一致
                    if (userPwd == usermodel.LoginPwd)
                    {
                        //先赋值 才能跳转
                        Session["usermodel"] = usermodel;

                        //Response.Redirect("SessionSuc.aspx");
                        UserPwd  = userPwd;
                        UserName = userName;
                        Checked  = "checked";
                        //Request.Cookies["ck1"].Expires = DateTime.Now.AddDays(-1);
                        //Request.Cookies["ck2"].Expires = DateTime.Now.AddDays(-1);
                    }
                }
                //如果Cookie中是有值的,但是Cookie存储的用户名或密码不正确,表示用户名和密码被篡改了,那么只能继续出现登录页面。那么该 cOOKIE也没有必要存在了。
                Response.Cookies["ck1"].Expires = DateTime.Now.AddDays(-1);
                Response.Cookies["ck2"].Expires = DateTime.Now.AddDays(-1);
            }
        }
Пример #2
0
        /// <summary>
        ///展示要修改的数据
        /// </summary>
        private void ShowEdit()
        {
            int id;

            if (int.TryParse(Request.QueryString["id"], out id))
            {
                Users_Model usermodel = userservice.FindUser(id);
                UserModel = usermodel;
            }
        }
Пример #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int id = Convert.ToInt32(context.Request["id"]);

            BLL.User_Service userSer   = new BLL.User_Service();
            Users_Model      usermodel = userSer.FindUser(id);

            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
            context.Response.Write(js.Serialize(usermodel));
        }