HttpListenerResponse.SetCookie メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HttpListenerResponse.SetCookie メソッドの意味・解説 

HttpListenerResponse.SetCookie メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

この応答と共に送信されCookieコレクションに対して Cookie追加または更新します

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

例外例外
例外種類条件

ArgumentNullException

cookienull 参照 (Visual Basic では Nothing) です。

ArgumentException

Cookie が既にコレクション内に存在し置き換えることができません。

解説解説

NameDomain、および Path の各プロパティの値が同じ場合2 つCookie は同じと見なされます。これらの 3 つの情報が同じ場合、このメソッドCookie更新しようとします。名前とドメイン比較では大文字と小文字区別されませんが、パス比較では大文字と小文字区別されます。

使用例使用例

メソッド呼び出しについては、次のコード例参照してください

// This example requires the System and System.Net namespaces.
public static void SimpleCookieExample(string[]
 prefixes)
{
    // Create a listener.
    HttpListener listener = new HttpListener();
    // Add the prefixes.
    foreach (string s in
 prefixes)
    {
        listener.Prefixes.Add(s);
    }
    listener.Start();
    Console.WriteLine("Listening...");
    // Note: The GetContext method blocks while waiting for a request.
 
    HttpListenerContext context = listener.GetContext();
    HttpListenerRequest request = context.Request;
    
    // This application sends a cookie to the client marking the time
 
    // they visited. 
    Cookie timeStampCookie = new Cookie("VisitDate",
 DateTime.Now.ToString());
    // Obtain a response object.
    HttpListenerResponse response = context.Response;
    // Add the cookie to the response.
    response.SetCookie(timeStampCookie);
    // Construct a response.
    string responseString = "<HTML><BODY> Hello
 world!</BODY></HTML>";
    response.ContentEncoding = System.Text.Encoding.UTF8;
    byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
    // Send the response.
    response.Close(buffer, true);
    listener.Stop();
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HttpListenerResponse クラス
HttpListenerResponse メンバ
System.Net 名前空間
HttpListener クラス
HttpListenerContext クラス
HttpListenerRequest クラス


このページでは「.NET Framework クラス ライブラリ リファレンス」からHttpListenerResponse.SetCookie メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からHttpListenerResponse.SetCookie メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からHttpListenerResponse.SetCookie メソッド を検索

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

辞書ショートカット

すべての辞書の索引

HttpListenerResponse.SetCookie メソッドのお隣キーワード
検索ランキング

   

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



HttpListenerResponse.SetCookie メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS