Description
The GlobalProxySelection stores the proxy settings for the default proxy that System.Net.WebRequest instances use to contact Internet sites beyond the local network. The default proxy settings are initialized from a global or application configuration file, and can be overridden for individual requests, or disabled by setting the HttpWebRequest.Proxy property to the object returned by the GlobalProxySelection.GetEmptyWebProxy method.
The proxy settings stored in GlobalProxySelection are used by an HttpWebRequest instance if its HttpWebRequest.Proxy property is not set.
Example
using System;
using System.Net;
public class GlobalProxySelectionSample
{
public static void Main()
{
Uri target = new Uri("http://microsoft.com");
WebProxy wp = (WebProxy)GlobalProxySelection.Select;
Uri defaultProxy = wp.Address;
if (defaultProxy == null)
{
Console.WriteLine("No default proxy address found");
}
else
{
Console.WriteLine("Default proxy address is '{0}'",
defaultProxy);
}
}
}
The output is
Default proxy address is 'http://itgproxy/'
|