Leer en inglés

Compartir a través de


HttpListener.IgnoreWriteExceptions Propiedad

Definición

Obtiene o establece un valor Boolean que especifica si su aplicación recibe las excepciones que aparecen cuando HttpListener envía la respuesta al cliente.

C#
public bool IgnoreWriteExceptions { get; set; }

Valor de propiedad

true es si esto HttpListener no debe devolver excepciones que se producen al enviar la respuesta al cliente; de lo contrario, falsees . El valor predeterminado es false.

Excepciones

Este objeto se ha cerrado.

Ejemplos

En el ejemplo de código siguiente se muestra cómo establecer esta propiedad.

C#
public static void SimpleListenerWithUnsafeAuthentication(string[] prefixes)
{
    // URI prefixes are required,
    // for example "http://contoso.com:8080/index/".
    if (prefixes == null || prefixes.Length == 0)
      throw new ArgumentException("prefixes");
    // Set up a listener.
    HttpListener listener = new HttpListener();
    foreach (string s in prefixes)
    {
        listener.Prefixes.Add(s);
    }
    listener.Start();
    // Specify Negotiate as the authentication scheme.
    listener.AuthenticationSchemes = AuthenticationSchemes.Negotiate;
    // If NTLM is used, we will allow multiple requests on the same
    // connection to use the authentication information of first request.
    // This improves performance but does reduce the security of your
    // application.
    listener.UnsafeConnectionNtlmAuthentication = true;
    // This listener does not want to receive exceptions
    // that occur when sending the response to the client.
    listener.IgnoreWriteExceptions = true;
    Console.WriteLine("Listening...");
    // ... process requests here.

    listener.Close();
}

Comentarios

Establezca esta propiedad true en si la aplicación no requiere que una respuesta se envíe correctamente a cada cliente.

Se aplica a

Producto Versiones
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1