Exemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            int id;

            if (int.TryParse(context.Request.QueryString["id"], out id))
            {
                BLL.UserInfoService UserInfoService = new BLL.UserInfoService();
                UserInfo            userInfo        = UserInfoService.GetUserInfo(id);
                if (userInfo != null)
                {
                    //读取模板文件,替换表单中的占位符.
                    string filePath    = context.Request.MapPath("ShowEditUser.html");
                    string fileContent = File.ReadAllText(filePath);
                    fileContent = fileContent.Replace("$name", userInfo.UserName).Replace("$pwd", userInfo.UserPass).Replace("$mail", userInfo.Email).Replace("$Id", userInfo.Id.ToString());
                    context.Response.Write(fileContent);
                }
                else
                {
                    context.Response.Write("查无此人!!");
                }
            }
            else
            {
                context.Response.Write("参数错误!!");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 通过检查cookie信息 来自动登录
        /// </summary>
        protected void CheckCookieInfo()
        {
            if (Request.Cookies["cp1"] != null && Request.Cookies["cp2"] != null)
            {
                string userName = Request.Cookies["cp1"].Value;
                string userPwd  = Request.Cookies["cp2"].Value;


                BLL.UserInfoService userInfoService = new BLL.UserInfoService();
                UserInfo            userInfo        = userInfoService.GetUserInfo(userName);
                if (userInfo != null)
                {
                    //注意:在添加用户或注册用户时一定要将用户输入的密码加密以后在存储到数据库中。
                    string localPwd = WebCommon.GetMd5(WebCommon.GetMd5(userInfo.UserPass));
                    if (localPwd == userPwd)
                    {
                        Session["userInfo"] = userInfo;
                        Response.Redirect("UserInfoList.aspx");
                    }
                }
                else
                {
                    //数据库 数据别人盗取了。
                    // cookie当中数据如果错误了 cookie中的数据 清空
                    Response.Cookies["cp1"].Expires = DateTime.Now.AddDays(-1);
                    Response.Cookies["cp2"].Expires = DateTime.Now.AddDays(-1);
                }
            }
            else
            {
                //这里就直接出现登陆页面 不用其他的处理
            }
        }
Exemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            int id;

            if (int.TryParse(context.Request.QueryString["uid"], out id))
            {
                BLL.UserInfoService UserInfoService = new BLL.UserInfoService();
                UserInfo            userInfo        = UserInfoService.GetUserInfo(id);//获取用户的信息.
                if (userInfo != null)
                {
                    string filePath    = context.Request.MapPath("Detail.html");
                    string fileContent = File.ReadAllText(filePath);
                    fileContent = fileContent.Replace("$name", userInfo.UserName).Replace("$pwd", userInfo.UserPass);
                    context.Response.Write(fileContent);
                }
                else
                {
                    context.Response.Redirect("Error.html");
                }
            }
            else
            {
                context.Response.Write("参数错误!!");
            }
        }
Exemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int id = Convert.ToInt32(context.Request["id"]);

            BLL.UserInfoService UserInfoService = new BLL.UserInfoService();
            UserInfo            userInfo        = UserInfoService.GetUserInfo(id);

            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
            context.Response.Write(js.Serialize(userInfo));
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request["id"]);

            BLL.UserInfoService UserInfoService = new BLL.UserInfoService();
            UserInfo            userInfo        = UserInfoService.GetUserInfo(id);
            List <UserInfo>     list            = new List <UserInfo>();

            list.Add(userInfo);
            this.DetailsView1.DataSource = list;
            this.DetailsView1.DataBind();
        }
Exemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string userName = context.Request["name"];

            BLL.UserInfoService UserInfoService = new BLL.UserInfoService();
            if (UserInfoService.GetUserInfo(userName) != null)
            {
                context.Response.Write("此用户名已存在!!");
            }
            else
            {
                context.Response.Write("此用户名可用!!");
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 展示要修改的用户的信息
        /// </summary>
        protected void ShowEditUserInfo()
        {
            int id;

            if (int.TryParse(Request.QueryString["id"], out id))
            {
                UserInfo userInfo = UserInfoService.GetUserInfo(id);
                if (userInfo != null)
                {
                    EditUserInfo = userInfo;
                }
                else
                {
                    Response.Redirect("/Error.html");
                }
            }
            else
            {
                Response.Redirect("/Error.html");
            }
        }
Exemplo n.º 8
0
 protected void CheckCookieInfo()
 {
     if (Request.Cookies["cp1"] != null && Request.Cookies["cp2"] != null)
     {
         string userName = Request.Cookies["cp1"].Value;
         string userPwd  = Request.Cookies["cp2"].Value;
         //校验
         BLL.UserInfoService UserInfoService = new BLL.UserInfoService();
         UserInfo            userInfo        = UserInfoService.GetUserInfo(userName);
         if (userInfo != null)
         {
             //注意:在添加用户或注册用户时一定要将用户输入的密码加密以后在存储到数据库中。
             if (userPwd == Common.WebCommon.GetMd5String(Common.WebCommon.GetMd5String(userInfo.UserPass)))
             {
                 Session["userInfo"] = userInfo;
                 Response.Redirect("UserInfoList.aspx");
             }
         }
         Response.Cookies["cp1"].Expires = DateTime.Now.AddDays(-1);
         Response.Cookies["cp2"].Expires = DateTime.Now.AddDays(-1);
     }
 }
Exemplo n.º 9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //接收数据.
            //  UserInfo userInfo = new UserInfo();
            int id = Convert.ToInt32(context.Request.Form["txtId"]);//接收隐藏中的值

            BLL.UserInfoService UserInfoService = new BLL.UserInfoService();
            UserInfo            userInfo        = UserInfoService.GetUserInfo(id);

            userInfo.UserName = context.Request.Form["txtName"];
            userInfo.UserPass = context.Request.Form["txtPwd"];
            userInfo.Email    = context.Request.Form["txtMail"];
            if (UserInfoService.EditUserInfo(userInfo))
            {
                context.Response.Redirect("UserInfoList.ashx");
            }
            else
            {
                context.Response.Redirect("Error.html");
            }
        }