The System.Net.WebProxy instance to use as a proxy for the current instance. The default value is set by calling GlobalProxySelection.Select .
Type Reason ArgumentNullException A set operation was requested and the specified value was null. InvalidOperationException A set operation was requested but data has already been sent to the request stream. System.Security.SecurityException The caller does not have permission for the requested operation.
The HttpWebRequest.Proxy property identifies the System.Net.WebProxy object to use to process requests to Internet resources. To specify that no proxy should be used, set the HttpWebRequest.Proxy property to the proxy instance returned by the GlobalProxySelection.GetEmptyWebProxy method.
The local computer or application config file may specify that a default proxy be used. If the HttpWebRequest.Proxy property is specified, then the proxy settings from the HttpWebRequest.Proxy property override the local computer or application config file and the System.Net.HttpWebRequest instance will use the proxy settings specified. If no proxy is specified in a config file and the HttpWebRequest.Proxy property is unspecified, the System.Net.HttpWebRequest class uses the proxy settings inherited from Internet Explorer on the local computer. If there are no proxy settings in Internet Explorer, the request is sent directly to the server.
The System.Net.HttpWebRequest class parses a proxy bypass list with wildcard characters inherited from Internet Explorer the same as the bypass list is parsed directly by Internet Explorer. For example, the System.Net.HttpWebRequest class will parse a bypass list of "nt*" from Internet Explorer as a regular expression of "nt.*". So a URL of "http://nt.com" would bypass the proxy using the System.Net.HttpWebRequest class and using Internet Explorer.
The System.Net.HttpWebRequest class supports local proxy bypass. The class considers a destination to be local if any of the following conditions are met:
The destination contains a flat name (no dots in the URL).
The destination contains a loopback address (IPAddress.Loopback or IPAddress.IPv6Loopback) or the destination contains an System.Net.IPAddress assigned to the local computer.
The domain suffix of the destination matches the local computer's domain suffix (System.Net.NetworkInformation.IPGlobalProperties.DomainName).
Changing the HttpWebRequest.Proxy property after the request has been started by calling the HttpWebRequest.GetRequestStream, HttpWebRequest.BeginGetRequestStream(AsyncCallback, object), HttpWebRequest.GetResponse, or HttpWebRequest.BeginGetResponse(AsyncCallback, object) method throws an InvalidOperationException. For information on the proxy element see DefaultProxy Element (Network Settings).
Type | Reason |
---|---|
!:System.Security.Permissions.WebPermission | Requires unrestricted System.Net.WebPermission. See System.Security.Permissions.PermissionState.Unrestricted. |