免费男女视频_国产系列 视频二区_羞羞视频免费入口网站_久国久产久精永久网页_国产免费观看av_一区二区三区日韩在线观看

FormsAuthenticationTicket 类

提供對票證的屬性和值的訪問,這些票證用于 Forms 身份驗證對用戶進行標識。無法繼承此類。

命名空間:System.Web.Security
程序集:System.Web(在 system.web.dll 中)

備注

 

FormsAuthenticationTicket 類用于創建表示身份驗證票證的對象,Forms 身份驗證使用這些票證來標識已經過身份驗證的用戶。Forms 身份驗證票證的屬性和值將轉換為加密字符串存儲在 Cookie 或 URL 中;這些加密字符串也會轉換回票證的屬性和值。

FormsAuthentication 類提供了 Encrypt 方法,用于從 FormsAuthenticationTicket 創建一個可存儲在 Cookie 或 URL 中的字符串值。FormsAuthentication 類還提供了一個 Decrypt 方法,用于從檢索自 Forms 身份驗證 Cookie 或 URL 的加密身份驗證票證創建一個 FormsAuthenticationTicket 對象。

可以使用 FormsIdentity 類的 Ticket 屬性訪問當前經過身份驗證的用戶的 FormsAuthenticationTicket。通過將當前 UserIdentity 屬性強制轉換為類型 FormsIdentity,可以訪問當前 FormsIdentity 對象

下面的代碼示例使用 FormsCookieNameEncrypt 方法的結果存儲在 Cookie 中,并將用戶重定向到從 GetRedirectUrl 方法返回的 URL。

C#
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>
<script runat="server"> private void Login_Click(Object sender, EventArgs e)
  {  // Create a custom FormsAuthenticationTicket containing  // application specific data for the user.  string username     = UserNameTextBox.Text; string password     = UserPassTextBox.Text;  bool isPersistent = PersistCheckBox.Checked; if (Membership.ValidateUser(username, password))
    { string userData = "ApplicationSpecific data for this user.";

      FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
        username,
        DateTime.Now,
        DateTime.Now.AddMinutes(30),
        isPersistent,
        userData,
        FormsAuthentication.FormsCookiePath); // Encrypt the ticket.  string encTicket = FormsAuthentication.Encrypt(ticket);  // Create the cookie. Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
       // Redirect back to original URL. Response.Redirect(FormsAuthentication.GetRedirectUrl(username, isPersistent));
    } else {
      Msg.Text = "Login failed. Please check your user name and password and try again.";
    }
  }

</script>
<html>
<head>
    <title>Forms Authentication Login</title>
</head>
<body>
    <form runat="server">
        <span style="BACKGROUND: #80ff80"> 
          <h3>Login Page</h3>
        </span> 
        <asp:Label id="Msg" ForeColor="maroon" runat="server" /><P>
        <table border=0>
            <tbody>
                <tr>
                    <td>Username:</td>
                    <td><asp:TextBox id="UserNameTextBox" type="text" runat="server" /></td>
                    <td>
                      <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="*" Display="Static" ControlToValidate="UserNameTextBox" />
                    </td>
                </tr>
                <tr>
                    <td>Password:</td>
                    <td><asp:TextBox id="UserPassTextBox" TextMode="Password" runat="server" /></td>
                    <td>
                      <asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ErrorMessage="*" Display="Static" ControlToValidate="UserPassTextBox" />
                    </td>
                </tr>
                <tr>
                    <td>Check here if this is <u>not</u><br>a public computer:</td>
                    <td><asp:CheckBox id="PersistCheckBox" runat="server" autopostback="true" /></td>
                </tr>
            </tbody>
        </table>
        <input type="submit" value="Login" runat="server" onserverclick="Login_Click" />
    </form>
</body>
</html>

 

繼承層次結構
 

System.Object
System.Web.Security.FormsAuthenticationTicket

 

線程安全
 

此類型的任何公共靜態(Visual Basic 中的 Shared)成員都是線程安全的,但不保證所有實例成員都是線程安全的。

 

平臺
 

Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

主站蜘蛛池模板: 久久久久久艹 | 92看片淫黄大片一级 | 一区二区三区欧美精品 | 99成人精品视频 | 欧美成人精品一区二区 | 黄色免费入口 | 毛片免费观看视频 | 午夜视频久久久 | 亚洲一区二区三区精品在线观看 | 一级一级一级毛片 | 羞羞的视频在线免费观看 | 精品国产99久久久久久宅男i | 91丝袜| 91精品国产日韩91久久久久久360 | 看一级大毛片 | 国产精品av久久久久久网址 | 强伦女教师视频 | 久色成人网 | 国产免费观看a大片的网站 欧美成人一级 | 国产午夜电影在线观看 | 久久91精品久久久久清纯 | 国产一级免费在线视频 | 特级毛片全部免费播放器 | 成人在线视频一区 | 护士xxxx | 成人三级电影网址 | 国产99久久精品一区二区 | 伊人在线 | 精品一区二区三区免费爱 | av在线播放电影 | 国产chinesehd精品91 | 国产一级aaa全黄毛片 | 成年人国产视频 | 色人阁导航 | 97人操 | 久久亚洲精品久久国产一区二区 | 麻豆视频国产在线观看 | 欧美成人精品一区二区男人小说 | 亚洲第一男人天堂 | 中文字幕精品在线播放 | 91社区在线观看 |