Leer en inglés

Compartir a través de


IWebProxy.IsBypassed(Uri) Método

Definición

Indica que el proxy no debe utilizarse para el host especificado.

C#
public bool IsBypassed(Uri host);

Parámetros

host
Uri

Uri del host que se comprobará para el uso del proxy.

Devoluciones

Es true si el servidor proxy no se debe utilizar para host; de lo contrario, es false.

Ejemplos

En el ejemplo siguiente se usa la IsBypassed propiedad para determinar si se debe usar el servidor proxy para el host especificado.

C#
WebProxy_Interface webProxy_Interface = new WebProxy_Interface(new Uri("http://proxy.example.com"));

webProxy_Interface.Credentials = new NetworkCredential("myusername", "mypassword");

Uri testUri = new Uri("http://www.contoso.com");

// Determine whether the Web proxy can be bypassed for the site "http://www.contoso.com".
if(webProxy_Interface.IsBypassed(testUri))
{
    Console.WriteLine("Web Proxy is by passed");
}
else
{
    Uri? webProxyServer = webProxy_Interface.GetProxy(testUri);
    // In general, we wouldn't expect the condition (`webProxyServer! == testUri`) true here, if  IsBypassed returns `false`.
    // However, technically our interface can allow that.
    if (webProxyServer is null || webProxyServer! == testUri)
    {
        Console.WriteLine("Web proxy is bypassed");
    }
    else
    {
        Console.WriteLine("Web proxy is not bypassed");
        Console.WriteLine($"The web proxy is: {webProxyServer!}");
    }
}

Comentarios

El IsBypassed método indica si se debe usar el servidor proxy para tener acceso al host especificado en el host parámetro . Si IsBypassed devuelve true, el proxy no se usa para ponerse en contacto con el host y la solicitud se pasa directamente al servidor. La obtención false de no IsBypassed garantiza que el URI esté proxiado; todavía tiene que llamar al GetProxy método para determinarlo.

Se aplica a

Producto Versiones
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 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 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0