免费男女视频_国产系列 视频二区_羞羞视频免费入口网站_久国久产久精永久网页_国产免费观看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

主站蜘蛛池模板: 人人做人人看 | 精品国产一区二区三区四 | 中国hdxxxx护士爽在线观看 | 最新91在线视频 | 国产午夜精品久久久 | 黄色大片大毛片 | 色骚综合 | 成人在线网站 | 久久久久久久久久亚洲 | 久久国产精品久久久久久久久久 | 久久精品网站视频 | 黄色aaa视频| 国产精品久久久久网站 | 羞羞网站入口 | 国产乱色精品成人免费视频 | 亚洲午夜不卡 | 色中色激情影院 | 国产1区2区3区中文字幕 | 精品在线免费播放 | 人成久久| 一级国产航空美女毛片内谢 | 国产91在线播放九色 | 97视频| 黄色片网站免费观看 | 手机av免费电影 | 夜夜看| 色999中文字幕 | 色视频在线 | 羞羞视频2023 | 国产一区精品在线观看 | 91成人免费视频 | 亚洲精品久久久久久久久久 | 亚洲一区二区三区视频免费 | 国产成人高潮免费观看精品 | 久久精品视频免费观看 | 韩国美女一区 | 国产伦乱视频 | 久久思思爱 | 国产精品一区在线看 | 中文字幕免费在线看 | 一区二区三区四区视频在线观看 |