zoukankan      html  css  js  c++  java
  • 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();
            }
     

  • 相关阅读:
    Compiling LIBFFM On OSX 10.9
    Linux shell 脚本入门教程+实例
    Understanding the Bias-Variance Tradeoff
    Learning How To Code Neural Networks
    MXNet设计和实现简介
    数据需求统计常用awk命令
    Deal with relational data using libFM with blocks
    MATLAB 在同一个m文件中写多个独立的功能函数
    Debug 路漫漫-06
    MATLAB 求两个矩阵的 欧氏距离
  • 原文地址:https://www.cnblogs.com/humble/p/3135532.html
Copyright © 2011-2022 走看看