/// <summary> /// 检查用户存储的cookie信息 /// </summary> /// <returns></returns> private void CheckUserInfo() { if (Request.Cookies["c1"] != null && Request.Cookies["c1"].Value != "" && Request.Cookies["c2"] != null && Request.Cookies["c2"].Value != "") { Users u = new UsersBLL().GetModelByLoginId(Request.Cookies["c1"].Value); if (u != null) { if (u.LoginPwd == Request.Cookies["c2"].Value) { LoginSucess(u); } else { ClearCookies(); } } } else { if (Request.Cookies["userInfo"] != null && Request.Cookies["userInfo"].ToString() != "") { string key = Request.Cookies["userInfo"].Value; object obj = Common.MemCacheHelper.GetValue(key); if (obj != null) { Response.Redirect("/BookList.aspx"); } } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string msg = "激活链接无效!"; int id; if (int.TryParse(context.Request.QueryString["uid"], out id)) { string code = context.Request.QueryString["code"]; if (!string.IsNullOrEmpty(code)) { UsersBLL ub = new UsersBLL(); Users u = ub.GetModel(id); if (u != null && u.ActiveCode == code) { if (u.Actived == false) { if ((ub.SetActived(id))) { msg = "账户激活成功!"; } else { msg = "账户激活失败!"; } } else { msg = "账户已激活!"; } } } } context.Response.Redirect("/ShowMsg.aspx?m=" + HttpUtility.UrlEncode(msg) + "&t=" + HttpUtility.UrlEncode("登陆页面") + "&u=/Login.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { if (CheckCode()) { Users u = new Users(); u.LoginId = Request.Form["txtName"]; u.LoginPwd = Common.WebCommon.GetStrDoubleMD5(Request.Form["txtPass"]); u.Name = Request.Form["txtTrueName"]; u.Mail = Request.Form["txtEmail"]; u.Address = Request.Form["txtAddress"]; u.Phone = Request.Form["txtPhone"]; u.UserState.Id = 1; u.ActiveCode = Guid.NewGuid().ToString().Replace("-", ""); string msg; UsersBLL ub = new UsersBLL(); int uid = ub.Add(u, out msg); if (uid > 0) { //注册成功 //发送激活链接 string link = "http://*****:*****@"亲爱的网上图书商城用户:<br /><br /><br /> // 请通过<a target='_blank' href='{0}'>{1}</a>激活账号,也可以复制激活链接至浏览器 // <br /><br /><br /> // 网上图书商城 // <br /> // {2} // <br /><br /><br /> // 此邮件为系统自动发出的邮件,请勿直接回复。", link, link, DateTime.Now.ToString()); #endregion string content = string.Format(new SettingsBLL().GetValueByName("激活邮件内容"), link, link, DateTime.Now.ToString()); string subject = "来自网上图书商城的注册确认邮件"; ub.SendEmail(content, u.Mail, subject); //页面的跳转 Response.Redirect("/ShowMsg.aspx?m=" + HttpUtility.UrlEncode(msg+"<br />激活邮件已发到您的"+u.Mail+"的邮箱中,请激活账号后登录!") + "&t=" + HttpUtility.UrlEncode("登录页面") + "&u=/Member/Login.aspx"); } else { //注册失败 txtMsg.Text = msg; txtMsg.ForeColor = Color.Red; } } else { txtMsg.Text = "验证码错误,请重新输入!"; txtMsg.ForeColor = Color.Red; } } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { string name = Request.Form["txtName"]; string email = Request.Form["txtEmail"]; string msg = string.Empty; if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(email)) { if (CheckCode()) { UsersBLL ub = new UsersBLL(); Users u = ub.GetModelByLoginId(name); if (u != null) { if (u.Mail == email) { string link = "http://*****:*****@"亲爱的用户 {0}:您好!<br /><br /> // 您收到这封这封电子邮件是因为您 (也可能是某人冒充您的名义) 申请了一个新的密码。假如这不是您本人所申请, 请不用理会这 封电子邮件, 但是如果您持续收到这类的信件骚扰, 请您尽快联络管理员。<br /><br /> // 要使用新的密码, 请使用以下链接启用密码。<br /><br /> // <a href='{1}' target='_blank'>{2}</a><br /><br /> // (如果无法点击该URL链接地址,请将它复制并粘帖到浏览器的地址输入框,然后单击回车即可。该链接使用后将立即失效。)<br /><br /> // 注意:请您在收到邮件1个小时内({3}前)使用,否则该链接将会失效。<br /><br /> // 网上图书商城",u.Name, link, link, DateTime.Now.AddHours(1).ToString("yyyy-MM-dd HH:mm:ss")); string content = string.Format(new SettingsBLL().GetValueByName("找回密码邮件内容"), u.Name, link, link, DateTime.Now.AddHours(1).ToString("yyyy-MM-dd HH:mm:ss")); string subject = "来自网上图书商城的找回密码邮件"; ub.SendEmail(content, u.Mail, subject); msg = "您的申请已经提交成功,请查看您的邮箱。"; Response.Redirect("/ShowMsg.aspx?m=" + HttpUtility.UrlEncode(msg) + "&t=" + HttpUtility.UrlEncode("首页") + "&u=/Default.aspx"); } else { msg = "邮箱输入错误!"; } } else { msg = "用户名不存在!"; } } else { msg = "验证码输入错误!"; } } else { msg = "用户名和邮箱不能为空!"; } txtMsg.Text = msg; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int uid; string code = Request.QueryString["code"]; string msg = ""; if (int.TryParse(Request.QueryString["uid"], out uid)) { if (!string.IsNullOrEmpty(code)) { Users u = new UsersBLL().GetModel(uid); if (u != null) { lblName.Text = u.LoginId; hdUid.Value = u.Id.ToString(); } else { msg = "用户不存在!"; } } else { msg = "参数错误!"; } } else { msg = "参数错误!"; } if (!string.IsNullOrEmpty(msg)) { Response.Redirect("/ShowMsg.aspx?m=" + HttpUtility.UrlEncode(msg) + "&t=" + HttpUtility.UrlEncode("首页") + "&u=/Default.aspx"); } } else { UsersBLL ub = new UsersBLL(); Users u = ub.GetModel(Convert.ToInt32(hdUid.Value)); u.LoginPwd = Request.Form["txtPass"]; if (ub.Update(u)) { ClearCookies(); Response.Redirect("/ShowMsg.aspx?m=" + HttpUtility.UrlEncode("修改密码成功,请重新登录!") + "&t=" + HttpUtility.UrlEncode("登录") + "&u=Login.aspx"); } else { txtMsg.Text = "修改密码失败!"; } } }
protected override void OnInit(EventArgs e) { base.OnInit(e); //if (Session["userInfo"] == null) //{ // WebCommon.GoPage(); //} if (Request.Cookies["c1"] != null && Request.Cookies["c1"].Value != "" && Request.Cookies["c2"] != null && Request.Cookies["c2"].Value != "") { Users u = new UsersBLL().GetModelByLoginId(Request.Cookies["c1"].Value); if (u != null) { if (u.LoginPwd == Request.Cookies["c2"].Value) { LoginUser = u; } else { WebCommon.GoPage(); } } } if (Request.Cookies["userInfo"] != null && Request.Cookies["userInfo"].ToString() != "") { string key = Request.Cookies["userInfo"].Value; object obj = Common.MemCacheHelper.GetValue(key, DateTime.Now.AddMinutes(20)); if (obj != null) { LoginUser = obj as Model.Users; } else { WebCommon.GoPage(); } } else { WebCommon.GoPage(); } }