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

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

HttpListenerContext.Response プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

クライアント要求応答してクライアント送信される HttpListenerResponse オブジェクト取得します

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

Dim instance As HttpListenerContext
Dim value As HttpListenerResponse

value = instance.Response
public HttpListenerResponse Response { get;
 }
public:
property HttpListenerResponse^ Response {
    HttpListenerResponse^ get ();
}
/** @property */
public HttpListenerResponse get_Response ()
public function get Response
 () : HttpListenerResponse

プロパティ
クライアント応答送り返すために使用する HttpListenerResponse オブジェクト

解説解説
使用例使用例

クライアント要求対す応答取得し応答本体追加するコード例次に示します

// This example requires the System and System.Net namespaces.
public static string ClientInformation(HttpListenerContext
 context)
{
    System.Security.Principal.IPrincipal user = context.User;
    System.Security.Principal.IIdentity id = user.Identity;
    if (id == null)
    {
        return "Client authentication is not enabled for
 this Web server.";
    }
    
    string display;
    if (id.IsAuthenticated)
    {
        display = String.Format("{0} was authenticated using
 {1}", id.Name, 
            id.AuthenticationType);
    }
    else
    {
       display = String.Format("{0} was not authenticated", id.Name);
    }
    return display;
}

public static void SimpleListenerWithAuthentication(string[]
 prefixes)
{
    if (!HttpListener.IsSupported)
    {
        Console.WriteLine ("Windows XP SP2 or Server 2003 is required to use
 the HttpListener class.");
        return;
    }

    // URI prefixes are required,
    // for example "http://contoso.com:8080/index/".
    if (prefixes == null || prefixes.Length
 == 0)
      throw new ArgumentException("prefixes");

    // Set up a listener.
    HttpListener listener = new HttpListener();
    foreach (string s in
 prefixes)
    {
        listener.Prefixes.Add(s);
    }
    listener.Start();
    // Specify Negotiate as the authentication scheme.
    listener.AuthenticationSchemes = AuthenticationSchemes.Negotiate;
    Console.WriteLine("Listening...");
    // GetContext blocks while waiting for a request. 
    HttpListenerContext context = listener.GetContext();
    HttpListenerRequest request = context.Request;
    // Obtain a response object.
    HttpListenerResponse response = context.Response;
    // Construct a response.
    string clientInformation = ClientInformation(context);
    byte[] buffer = System.Text.Encoding.UTF8.GetBytes("<HTML><BODY>
 " + clientInformation + "</BODY></HTML>");
    // Get a response stream and write the response to it.
    response.ContentLength64 = buffer.Length;
    System.IO.Stream output = response.OutputStream;
    output.Write(buffer,0,buffer.Length);
    output.Close();
    listener.Stop();
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HttpListenerContext クラス
HttpListenerContext メンバ
System.Net 名前空間


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

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

辞書ショートカット

すべての辞書の索引

「HttpListenerContext.Response プロパティ」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS