• MVC第三波书店登录


     

     #region 登录
            [HttpGet]
            public ActionResult Login()
            {
                return View();
            }
            [HttpPost]
            public ActionResult Login(UserInfo users)
            {

                if (!users.CheckNo.ToLower().Equals(TempData["code"].ToString()))
                {
                    return Content("");
                }
                else
                {
                    //记住用户名和密码
                    if (!string.IsNullOrEmpty(users.Removeme))
                    {
                        HttpCookie IdCookie = new HttpCookie("loginId", users.AccountNum);
                        IdCookie.Expires = DateTime.MaxValue;
                        IdCookie.HttpOnly = true;
                        Response.Cookies.Add(IdCookie);
                        HttpCookie PwdCookie = new HttpCookie("loginPwd", users.PassWord);
                        PwdCookie.Expires = DateTime.MaxValue;
                        PwdCookie.HttpOnly = true;
                        Response.Cookies.Add(PwdCookie);
                    }
                    else
                    {
                        Response.Cookies["loginId"].Expires = DateTime.Now.AddDays(-1);
                        Response.Cookies["loginPwd"].Expires = DateTime.Now.AddDays(-1);
                    }
                    return  RedirectToAction("Index");
                }
            }

            
          
            #endregion

    #region 登录
            [HttpGet]
            public ActionResult Login()
            {
                return View();
            }
            [HttpPost]
            public ActionResult Login(UserInfo users)
            {

                if (!users.CheckNo.ToLower().Equals(TempData["code"].ToString()))
                {
                    return Content("");
                }
                else
                {
                    //记住用户名和密码
                    if (!string.IsNullOrEmpty(users.Removeme))
                    {
                        HttpCookie IdCookie = new HttpCookie("loginId", users.AccountNum);
                        IdCookie.Expires = DateTime.MaxValue;
                        IdCookie.HttpOnly = true;
                        Response.Cookies.Add(IdCookie);
                        HttpCookie PwdCookie = new HttpCookie("loginPwd", users.PassWord);
                        PwdCookie.Expires = DateTime.MaxValue;
                        PwdCookie.HttpOnly = true;
                        Response.Cookies.Add(PwdCookie);
                    }
                    else
                    {
                        Response.Cookies["loginId"].Expires = DateTime.Now.AddDays(-1);
                        Response.Cookies["loginPwd"].Expires = DateTime.Now.AddDays(-1);
                    }
                    return  RedirectToAction("Index");
                }
            }

            
          
            #endregion

  • 相关阅读:
    Worthington果胶酶的特性及测定方案
    文件系统监视器
    SQL当前查询条件数据需要调用其他数据时创建临时表实现
    [算法2-数组与字符串的查找与匹配] (.NET源码学习)
    财务领域的数字助手,银企对账与到账通知软件机器人
    spring切面编程 之 注解实战
    从0开发一个Chrome插件:用户反馈与更新 Chrome 插件
    分享微信使用技巧,快来涨姿势啦
    Windows 和 Linux 下后台运行 Jar包
    k8s中的容器
  • 原文地址:https://blog.csdn.net/m0_74456535/article/details/127874538