Skip to content

Instantly share code, notes, and snippets.

@davidsh
davidsh / DotNetProxySupport.cs
Last active July 15, 2024 22:07
Background on .NET Framework and .NET Core proxy support
// WebRequest started it all. HttpWebRequest, FtpWebRequest, FileWebRequest, etc.
// Initial values when starting. The represents an object wrapping the platform/system proxy configuration settings.
// On Windows, these settings are from the IE setting dialog ("Wininet settings").
Console.WriteLine(WebRequest.DefaultWebProxy); // Internal type "System.Net.WebRequest+WebProxyWrapper"
Console.WriteLine(WebRequest.DefaultWebProxy.Credentials); // "null"
// HttpWebRequest has a single property, 'Proxy'. If null, it should not use a proxy. If non-null, then it
// should use a proxy. The initial value is non-null and the proxy to use is the platform/system proxy.
HttpWebRequest hwr = WebRequest.CreateHttp("http://www.contoso.com");