HttpListener.Prefixes Właściwość

Definicja

Pobiera prefiksy identyfikatora URI (Uniform Resource Identifier) obsługiwane przez ten HttpListener obiekt.

public:
 property System::Net::HttpListenerPrefixCollection ^ Prefixes { System::Net::HttpListenerPrefixCollection ^ get(); };
public System.Net.HttpListenerPrefixCollection Prefixes { get; }
member this.Prefixes : System.Net.HttpListenerPrefixCollection
Public ReadOnly Property Prefixes As HttpListenerPrefixCollection

Wartość właściwości

HttpListenerPrefixCollection

Element HttpListenerPrefixCollection zawierający prefiksy identyfikatorów URI skonfigurowane do obsługi tego HttpListener obiektu.

Wyjątki

Ten obiekt został zamknięty.

Przykłady

W poniższym przykładzie kodu pokazano użycie Prefixes właściwości w celu uzyskania i wydrukowania prefiksów identyfikatora URI, które są obsługiwane.

public static void DisplayPrefixesAndState(HttpListener listener)
{
    // List the prefixes to which the server listens.
    HttpListenerPrefixCollection prefixes = listener.Prefixes;
    if (prefixes.Count == 0)
    {
        Console.WriteLine("There are no prefixes.");
    }
    foreach(string prefix in prefixes)
    {
        Console.WriteLine(prefix);
    }
    // Show the listening state.
    if (listener.IsListening)
    {
        Console.WriteLine("The server is listening.");
    }
}
Public Shared Sub DisplayPrefixesAndState(ByVal listener As HttpListener)
    ' List the prefixes to which the server listens.
    Dim prefixes As HttpListenerPrefixCollection = listener.Prefixes

    If prefixes.Count = 0 Then
        Console.WriteLine("There are no prefixes.")
    End If

    For Each prefix As String In prefixes
        Console.WriteLine(prefix)
    Next

    ' Show the listening state.
    If listener.IsListening Then
        Console.WriteLine("The server is listening.")
    End If
End Sub

Uwagi

Prefiksy są w postaci kanonicznej. Aby uzyskać szczegółowy opis prefiksów, zobacz HttpListener omówienie klasy.

Dotyczy