HttpClient.DefaultProxy HttpClient.DefaultProxy HttpClient.DefaultProxy HttpClient.DefaultProxy Property

Definition

Gets or sets the global Http proxy.

public:
 static property System::Net::IWebProxy ^ DefaultProxy { System::Net::IWebProxy ^ get(); void set(System::Net::IWebProxy ^ value); };
public static System.Net.IWebProxy DefaultProxy { get; set; }
member this.DefaultProxy : System.Net.IWebProxy with get, set
Public Shared Property DefaultProxy As IWebProxy

Property Value

A proxy used by every call that instantiates a HttpWebRequest.

Exceptions

Remarks

This static property determines the default proxy that all HttpClient instances use if no proxy is set explicitly in the HttpClientHandler passed through its constructor.

The default instance returned by this property will initialize following a different set of rules depending on your platform:

  • For Windows: Reads proxy configuration from environment variables or, if those are not defined, from the user's proxy settings.

  • For macOS: Reads proxy configuration from environment variables or, if those are not defined, from the system's proxy settings.

  • For Linux: Reads proxy configuration from environment variables or, in case those are not defined, this property initializes a non-configured instance that bypasses all addresses.

The environment variables used for DefaultProxy initialization on Windows and Unix-based platforms are:

  • HTTP_PROXY: the hostname or IP address of the proxy server used on HTTP requests.
  • HTTPS_PROXY: the hostname or IP address of the proxy server used on HTTPS requests.
  • ALL_PROXY: the hostname or IP address of the proxy server used on HTTP and/or HTTPS requests in case HTTP_PROXY and/or HTTPS_PROXY are not defined.
  • NO_PROXY: a comma-separated list of hostnames that should be excluded from proxying.

Applies to