HttpListenerPrefixCollection.Clear Método

Definición

Quita todos los prefijos URI (Identificador uniforme de recursos) de la colección.

public:
 virtual void Clear();
public void Clear ();
abstract member Clear : unit -> unit
override this.Clear : unit -> unit
Public Sub Clear ()

Implementaciones

Excepciones

Error al llamar a una función de Windows. Examine la propiedad ErrorCode de la excepción para determinar su causa.

La clase HttpListener asociada a esta colección está cerrada.

Ejemplos

En el ejemplo de código siguiente se quitan todos los prefijos de .HttpListenerPrefixCollection

public static bool RemoveAllPrefixes(HttpListener listener)
{
    // Get the prefixes that the Web server is listening to.
    HttpListenerPrefixCollection prefixes = listener.Prefixes;
    try
    {
        prefixes.Clear();
    }
    // If the operation failed, return false.
    catch
    {
        return false;
    }
    return true;
}
Public Shared Function RemoveAllPrefixes(ByVal listener As HttpListener) As Boolean
    ' Get the prefixes that the Web server is listening to.
    Dim prefixes As HttpListenerPrefixCollection = listener.Prefixes

    Try
        prefixes.Clear()
    Catch ' If the operation failed, return false.
        Return False
    End Try

    Return True
End Function

Comentarios

Después de llamar a este método, no se puede iniciar el asociado HttpListener sin agregar nuevos prefijos; si intenta hacerlo, se produce una excepción.

Notas a los autores de las llamadas

Este miembro genera información de seguimiento cuando se habilita el seguimiento de red en la aplicación. Para obtener más información, vea Seguimiento de red en .NET Framework.

Se aplica a

Consulte también