WebProxy.BypassProxyOnLocal Property

Definition

Gets or sets a value that indicates whether to bypass the proxy server for local addresses.

C#
public bool BypassProxyOnLocal { get; set; }

Property Value

true to bypass the proxy server for local addresses; otherwise, false. The default value is false.

Examples

The following code example demonstrates calling a constructor that sets this property and getting the value of this property.

C#
public static WebProxy CreateProxyWithHostAddress(bool bypassLocal)
{
    WebProxy proxy =  new WebProxy("http://contoso", bypassLocal);
    Console.WriteLine("Bypass proxy for local URIs?: {0}",
       proxy.BypassProxyOnLocal);
    return proxy;
}

Remarks

The setting of the BypassProxyOnLocal property determines whether to use the proxy server when accessing local Internet resources.

If BypassProxyOnLocal is true, requests to local Internet resources do not use the proxy server. Local requests are identified by the lack of a period (.) in the URI, as in http://webserver/, or access the local server, including http://localhost, http://loopback, or http://127.0.0.1. When BypassProxyOnLocal is false, all Internet requests are made through the proxy server.

Napomena

Requests to a local host with a URI that contain a period use the proxy. To avoid using a proxy in these cases, create an entry for the host in the BypassList.

Applies to

Proizvod Verzije
.NET 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 2.0, 2.1