zoukankan      html  css  js  c++  java
  • asp.net FormsAuthentication 认证

    方法一,创建身份票据写cookie

                //创建身份验证票
                FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1"userInfo.UserName", DateTime.Now, DateTime.Now.AddMinutes(20), false"roles");
                
    //创建身份验证票的加密字符串
                string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
                
    //将加密字符串存储在 HttpCookie 对象中
                HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                
    //将此 cookie 添加到返回给用户浏览器的 cookie 集合中
                Response.Cookies.Add(authCookie);
                
    //将用户重定向到默认页
                Response.Redirect("~/Default.aspx");
    方法二,直接使用系统FormsAuthentication类自动创建身份票据写cookie
    FormsAuthentication.RedirectFromLoginPage(username, true);
    //按你设定的名字写入cookie.
    方法三,使用登陆控件asp:Login不用写代码。
  • 相关阅读:
    POJ 2661
    POJ 2643
    POJ 2656
    POJ 2612
    POJ 2636
    搭建WordPress个人博客
    【个人笔记】ximo早期发的脱壳教程——手脱UPX壳
    2.1【欢乐向】攻防世界新手逆向刷题被虐哭日常记录
    吾爱破解培训第一课个人笔记
    第五章 计算机组成
  • 原文地址:https://www.cnblogs.com/ejiyuan/p/1486497.html
Copyright © 2011-2022 走看看