Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Prefixes Property

HttpListener.Prefixes Property

Note: This property is new in the .NET Framework version 2.0.

Gets the Uniform Resource Identifier (URI) prefixes handled by this HttpListener object.

Namespace: System.Net
Assembly: System (in system.dll)

public HttpListenerPrefixCollection Prefixes { get; }
/** @property */
public HttpListenerPrefixCollection get_Prefixes ()

public function get Prefixes () : HttpListenerPrefixCollection

Property Value

An HttpListenerPrefixCollection that contains the URI prefixes that this HttpListener object is configured to handle.

Exception typeCondition

ObjectDisposedException

This object has been closed.

The prefixes are in canonical form. For a detailed description of prefixes, see the HttpListener class overview.

The following code example demonstrates using the Prefixes property to obtain and print the URI prefixes that are handled.

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.");
    }
}

Windows 98, Windows Server 2003, Windows XP Media Center Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2015 Microsoft