FormsAuthenticationTicket.CookiePath プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > FormsAuthenticationTicket.CookiePath プロパティの意味・解説 

FormsAuthenticationTicket.CookiePath プロパティ

フォーム認証チケットCookie パス取得します

名前空間: System.Web.Security
アセンブリ: System.Web (system.web.dll 内)
構文構文

Dim instance As FormsAuthenticationTicket
Dim value As String

value = instance.CookiePath
public string CookiePath { get;
 }
public:
property String^ CookiePath {
    String^ get ();
}
/** @property */
public String get_CookiePath ()

プロパティ
フォーム認証チケットCookie パス

解説解説

FormsAuthenticationTicket が cookiePath パラメータ提供しないコンストラクタ使用して作成されている場合CookiePath プロパティは FormsCookiePath プロパティの値を返しますそれ以外場合バージョン プロパティFormsAuthenticationTicket コンストラクタ提供された値を返します]:。

使用例使用例

現在ログオンしているユーザーについて、FormsAuthenticationTicket プロパティ値を表示するコード例次に示します

メモメモ

ログオンしているユーザーがいない場合Identity プロパティnull 参照 (Visual Basic では Nothing) になり、Identity プロパティを FormsIdentity オブジェクトとしてキャストするとコンパイラ例外生成されます。

<%@ Page Language="VB" AutoEventWireup="true"%>
<script runat="server">

    Sub Page_Load(sender As Object,
 e As EventArgs)
        Welcome.InnerHtml = "Hello, " + _
            Server.HtmlEncode(User.Identity.Name)
    
       Dim id As FormsIdentity = CType(User.Identity,
 FormsIdentity) 
       Dim ticket As FormsAuthenticationTicket
 = id.Ticket 

       cookiePath.Text = ticket.CookiePath
       expireDate.Text = ticket.Expiration.ToString()
       expired.Text = ticket.Expired.ToString()
       isPersistent.Text = ticket.IsPersistent.ToString()
       issueDate.Text = ticket.IssueDate.ToString()
       name.Text = ticket.Name
       userData.Text = ticket.UserData
       version.Text = ticket.Version.ToString()
    End Sub

    Sub Signout_Click(sender As Object,
 e As EventArgs)
        FormsAuthentication.SignOut()
        Response.Write("Logged out - cookie deleted.")
    End Sub

</script>
<html>
<head>
    <title>Forms Authentication</title>
</head>
<body>
    <h3>Forms Authentication Example</font> 
    </h3>
    <span id="Welcome" runat="server">
 </span>
    <form runat="server">
        <input type="submit" value="Signout"
 runat="server" onserverclick="Signout_Click"
 />
        <h3>Forms Authentication Ticket Properties</font> 
            <table>
                <tbody>
                    <tr>
                        <td>
                            CookiePath: 
                        </td>
                        <td><asp:Label id="cookiePath"
 runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Expiration: 
                        </td>
                        <td><asp:Label id="expireDate"
 runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Expired: 
                        </td>
                        <td><asp:Label id="expired"
 runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            IsPersistent: 
                        </td>
                        <td><asp:Label id="isPersistent"
 runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            IssueDate: 
                        </td>
                        <td><asp:Label id="issueDate"
 runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Name: 
                        </td>
                        <td><asp:Label id="name"
 runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            UserData: 
                        </td>
                        <td><asp:Label id="userData"
 runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Version: 
                        </td>
                        <td><asp:Label id="version"
 runat="server" />
                        </td>
                    </tr>
                </tbody>
            </table>
            <p>
            </p>
        </h3>
    </form>
    </span>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true"%>
<script runat="server">

    private void Page_Load(Object Src, EventArgs
 e)
    {
        Welcome.InnerHtml = "Hello, " +
            Server.HtmlEncode(User.Identity.Name);
    
       FormsIdentity id = (FormsIdentity)User.Identity;
       FormsAuthenticationTicket ticket = id.Ticket;
       
       cookiePath.Text = ticket.CookiePath;
       expireDate.Text = ticket.Expiration.ToString();
       expired.Text = ticket.Expired.ToString();
       isPersistent.Text = ticket.IsPersistent.ToString();
       issueDate.Text = ticket.IssueDate.ToString();
       name.Text = ticket.Name;
       userData.Text = ticket.UserData;
       version.Text = ticket.Version.ToString();
    
    
    }
    private void Signout_Click(Object sender,
 EventArgs e)
    {
        FormsAuthentication.SignOut();
        Response.Write("Logged out - cookie deleted.");
    }

</script>
<html>
<head>
    <title>Forms Authentication</title>
</head>
<body>
    <h3>Forms Authentication Example</font> 
    </h3>
    <span id="Welcome" runat="server"> </span>
    <form runat="server">
        <input type="submit" value="Signout" runat="server"
 onserverclick="Signout_Click" />
        <h3>Forms Authentication Ticket Properties</font> 
            <table>
                <tbody>
                    <tr>
                        <td>
                            CookiePath: 
                        </td>
                        <td><asp:Label id="cookiePath" runat="server"
 />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Expiration: 
                        </td>
                        <td><asp:Label id="expireDate" runat="server"
 />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Expired: 
                        </td>
                        <td><asp:Label id="expired" runat="server"
 />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            IsPersistent: 
                        </td>
                        <td><asp:Label id="isPersistent" runat="server"
 />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            IssueDate: 
                        </td>
                        <td><asp:Label id="issueDate" runat="server"
 />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Name: 
                        </td>
                        <td><asp:Label id="name" runat="server"
 />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            UserData: 
                        </td>
                        <td><asp:Label id="userData" runat="server"
 />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Version: 
                        </td>
                        <td><asp:Label id="version" runat="server"
 />
                        </td>
                    </tr>
                </tbody>
            </table>
            <p>
            </p>
        </h3>
    </form>
    </span>
</body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
FormsAuthenticationTicket クラス
FormsAuthenticationTicket メンバ
System.Web.Security 名前空間
その他の技術情報
フォーム認証プロバイダ



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

FormsAuthenticationTicket.CookiePath プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



FormsAuthenticationTicket.CookiePath プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS