Exemplo n.º 1
0
        protected void CheckUserInfo()
        {
            //获取用户输入的用户名和密码.
            string userName = Request.Form["txtName"];

            UserName = userName;
            string userPwd = Request.Form["txtPwd"];

            //校验用户名密码.
            BLL.UserInfoService UserInfoService = new BLL.UserInfoService();
            string   msg      = string.Empty;
            UserInfo userInfo = null;

            //判断用户名与密码
            if (UserInfoService.ValidateUserInfo(userName, userPwd, out msg, out userInfo))
            {
                //判断用户是否选择了“自动登录”
                if (!string.IsNullOrEmpty(Request.Form["autoLogin"]))//页面上如果有多个复选框时,只能将选中复选框的的值提交到服务端。
                {
                    HttpCookie cookie1 = new HttpCookie("cp1", userName);
                    HttpCookie cookie2 = new HttpCookie("cp2", Common.WebCommon.GetMd5String(Common.WebCommon.GetMd5String(userPwd)));
                    cookie1.Expires = DateTime.Now.AddDays(7);
                    cookie2.Expires = DateTime.Now.AddDays(7);
                    Response.Cookies.Add(cookie1);
                    Response.Cookies.Add(cookie2);
                }

                Session["userInfo"] = userInfo;
                Response.Redirect("UserInfoList.aspx");
            }
            else
            {
                Msg = msg;
            }
        }
Exemplo n.º 2
0
        protected void CheckUserInfo()
        {
            //session存储在内存中
            //不要将过大的数据复制给session
            //session要判断是否为空
            string userName = Request.Form["txtName"];

            UserName = userName;
            string userPwd = Request.Form["txtPwd"];

            BLL.UserInfoService userInfoService = new BLL.UserInfoService();
            string   msg      = string.Empty;
            UserInfo userInfo = null;

            bool isLogin = userInfoService.ValidateUserInfo(userName,
                                                            userPwd, out msg, out userInfo);

            //判断用户名密码是否正确
            if (isLogin)
            {
                //页面上如果有多个复选框时,只能将选中复选框的的值提交到服务端。
                if (!string.IsNullOrEmpty(Request.Form["autoLogin"]))
                {
                    string pwd = "";
                    //可以一种算法加密好几次 别人破解不了的那种

                    //第一次登陆的时候 加密之后保存到 cookie当中
                    // 第一次加载页面的 根据cookie的值来判断一下
                    pwd = WebCommon.GetMd5(WebCommon.GetMd5(userPwd));
                    HttpCookie cookie1 = new HttpCookie("cp1", userName);
                    HttpCookie cookie2 = new HttpCookie("cp2", pwd);
                    cookie1.Expires = DateTime.Now.AddDays(7);
                    cookie2.Expires = DateTime.Now.AddDays(7);
                    Response.Cookies.Add(cookie1);
                    Response.Cookies.Add(cookie2);
                }


                //Session过期了之后 就访问不打的
                //是滑动过期时间。再次访问的时候 时间 会往后延长
                //赋值几个页面 不要把所有的页面全部都复制过去
                Session["userInfo"] = userInfo;
                Response.Redirect("UserInfoList.aspx");
            }
            else
            {
                Msg = msg;
            }
        }
Exemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string userName = context.Request["userName"];
            string userPwd  = context.Request["userPwd"];

            BLL.UserInfoService UserInfoService = new BLL.UserInfoService();
            string   msg      = string.Empty;
            UserInfo userInfo = null;

            if (UserInfoService.ValidateUserInfo(userName, userPwd, out msg, out userInfo))
            {
                context.Session["userInfo"] = userInfo;
                context.Response.Write("ok:" + msg);
            }
            else
            {
                context.Response.Write("no:" + msg);
            }
        }
Exemplo n.º 4
0
        protected void CheckUserInfo()
        {
            //获取用户输入的用户名和密码.
            string userName = Request.Form["txtName"];

            UserName = userName;
            string userPwd = Request.Form["txtPwd"];

            //校验用户名密码.
            BLL.UserInfoService UserInfoService = new BLL.UserInfoService();
            string   msg      = string.Empty;
            UserInfo userInfo = null;

            //判断用户名与密码
            if (UserInfoService.ValidateUserInfo(userName, userPwd, out msg, out userInfo))
            {
                Session["userInfo"] = userInfo;
                Response.Redirect("UserInfoList.aspx");
            }
            else
            {
                Msg = msg;
            }
        }