• Form验证


      <system.web>
            <!--这里设置身份验证信息-->
        <authentication mode="Forms">
          <forms loginUrl="/Login/Login" timeout="2880" name="LyIng.Net" />
        </authentication>
     if (CheckLogin.Instance.Login(UserName, PassWord))
                    {
                        Users ModelUser = new Users() { ID = 10000, Name = UserName, UserName = UserName, PassWord = PassWord, Roles = "admin" };
                        string UserData = SerializeHelper.Instance.JsonSerialize<Users>(ModelUser);//序列化用户实体

                        //保存身份信息
                        FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(1, UserName, DateTime.Now, DateTime.Now.AddHours(12), false, UserData);
                        HttpCookie Cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(Ticket));//加密身份信息,保存至Cookie
                        Response.Cookies.Add(Cookie);
                        return Redirect("/Home/Index");
                    }

    public ActionResult Index()
            {
                System.Web.Security.FormsAuthentication.SetAuthCookie("qsmy_qin"true);
                return View();
            }
            
            public ActionResult Contact()
            {
                 
                bool d=Request.IsAuthenticated;
                return View();
            }
     

  • 相关阅读:
    DS博客作业06--图
    DS博客作业05--树
    DS博客作业04--树大作业说明
    DS博客作业02--栈和队列
    DS博客作业01--线性表
    DS博客作业01--日期抽象数据类型设计与实现
    C语言博客作业06--结构体&文件
    DEVC怎么建工程
    C语言博客05--指针
    201771010110孔维滢《面向对象程序设计(java)》第十二周学习总结
  • 原文地址:https://www.cnblogs.com/humble/p/3135532.html
Copyright © 2020-2023  润新知