HttpListenerPrefixCollectionとは? わかりやすく解説

HttpListenerPrefixCollection クラス

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

HttpListener オブジェクトの URI (Uniform Resource Identifier) プレフィックスの格納に使用するコレクションを表します。

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

Public Class HttpListenerPrefixCollection
    Implements ICollection(Of String),
 IEnumerable(Of String), _
    IEnumerable
Dim instance As HttpListenerPrefixCollection
public class HttpListenerPrefixCollection :
 ICollection<string>, IEnumerable<string>,
 
    IEnumerable
public ref class HttpListenerPrefixCollection
 : ICollection<String^>, IEnumerable<String^>, 
    IEnumerable
public class HttpListenerPrefixCollection implements
 ICollection<String>, 
    IEnumerable<String>, IEnumerable
public class HttpListenerPrefixCollection implements
 ICollection<String>, 
    IEnumerable<String>, IEnumerable
解説解説
使用例使用例

HttpListener を作成し、その HttpListenerPrefixCollection にユーザー指定のプレフィックスを追加するコード例を次に示します。

// This example requires the System and System.Net namespaces.
public static void SimpleListenerExample(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");
    
    // 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;
    // Obtain a response object.
    HttpListenerResponse response = context.Response;
    // Construct a response.
    string responseString = "<HTML><BODY> Hello
 world!</BODY></HTML>";
    byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
    // 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);
    // You must close the output stream.
    output.Close();
    listener.Stop();
}
継承階層継承階層
System.Object
  System.Net.HttpListenerPrefixCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HttpListenerPrefixCollection メンバ
System.Net 名前空間

HttpListenerPrefixCollection プロパティ


HttpListenerPrefixCollection メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.IEnumerable.GetEnumerator コレクションを反復処理するために使用できるオブジェクトを返します。
参照参照

関連項目

HttpListenerPrefixCollection クラス
System.Net 名前空間

HttpListenerPrefixCollection メンバ

HttpListener オブジェクトの URI (Uniform Resource Identifier) プレフィックスの格納に使用するコレクションを表します。

HttpListenerPrefixCollection データ型で公開されるメンバを以下の表に示します。


パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.IEnumerable.GetEnumerator コレクションを反復処理するために使用できるオブジェクトを返します。
参照参照

関連項目

HttpListenerPrefixCollection クラス
System.Net 名前空間



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「HttpListenerPrefixCollection」の関連用語

HttpListenerPrefixCollectionのお隣キーワード
検索ランキング

   

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



HttpListenerPrefixCollectionのページの著作権

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

©2026 GRAS Group, Inc.RSS