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不用写代码。
  • 相关阅读:
    CF1477F
    UR2 树上 GCD
    CF1491
    碎碎念——Nothing is but what is not
    理希的高考前胡诌
    理希的OI记——补集
    老年人的赛前康复计划
    react中受控组件、非受控组件、纯函数、高阶函数、高阶组件。
    react当中refs
    react当中Props
  • 原文地址:https://www.cnblogs.com/ejiyuan/p/1486497.html
Copyright © 2011-2022 走看看