Export (0) Print
Expand All

HttpListenerPrefixCollection.Remove Method

Removes the specified Uniform Resource Identifier (URI) from the list of prefixes handled by the HttpListener object.

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

'Declaration
Public Function Remove ( _
	uriPrefix As String _
) As Boolean
'Usage
Dim instance As HttpListenerPrefixCollection
Dim uriPrefix As String
Dim returnValue As Boolean

returnValue = instance.Remove(uriPrefix)
public final boolean Remove (
	String uriPrefix
)
public final function Remove (
	uriPrefix : String
) : boolean
Not applicable.

Parameters

uriPrefix

A String that contains the URI prefix to remove.

Return Value

true if the uriPrefix was found in the HttpListenerPrefixCollection and removed; otherwise false.

Exception typeCondition

ArgumentNullException

uriPrefix is a null reference (Nothing in Visual Basic).

HttpListenerException

A Windows function call failed. To determine the cause of the exception, check the exception's error code.

ObjectDisposedException

The HttpListener associated with this collection is closed.

If uriPrefix is not in the collection, this method does nothing.

Notes to Callers: This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing.

The following code example removes a user-specified prefix from a HttpListenerPrefixCollection.

public static boolean RemovePrefix(HttpListener listener, String prefix)
{
    // Get the prefixes that the Web server is listening to.
    HttpListenerPrefixCollection prefixes = listener.get_Prefixes();
    if (prefixes.get_Count() == 0 || prefix == null || prefix.get_Length() 
        == 0) {
        return false;
    }
    try {
        prefixes.Remove(prefix);
    }
    // If the operation failed, return false.
    catch (System.Exception exp) {
        return false;
    }
    return true;
} //RemovePrefix

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft