WebRequest.DefaultWebProxy Property

Definition

Gets or sets the global HTTP proxy.

C#
public static System.Net.IWebProxy DefaultWebProxy { get; set; }
C#
public static System.Net.IWebProxy? DefaultWebProxy { get; set; }

Property Value

An IWebProxy used by every call to instances of WebRequest.

Remarks

Caution

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete, and you shouldn't use them for new development. Use HttpClient instead.

The DefaultWebProxy property gets or sets the global proxy. The DefaultWebProxy property determines the default proxy that all WebRequest instances use if the request supports proxies and no proxy is set explicitly using the Proxy property. Proxies are currently supported by FtpWebRequest and HttpWebRequest.

The DefaultWebProxy property reads proxy settings from the app.config file. If there is no config file, the current user's Internet options proxy settings are used.

If the DefaultWebProxy property is set to null, all subsequent instances of the WebRequest class created by the Create or CreateDefault methods do not have a proxy.

Applies to

Product Versions
.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 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
UWP 10.0