The IWebProxy interface provides the methods and properties that are required by the WebRequest class to access proxy servers. The WebProxy class is the base implementation of the IWebProxy interface. Notes to Implementers. The GetProxy(Uri) method can be used to control proxy use based on the destination URI. Use the IsBypassed(Uri) method to indicate that the proxy should not be.
-->Definition
Contains HTTP proxy settings for the WebRequest class.
- Free web proxy to unblock sites and anonymous browsing. The Whoer.net anonymizer is a quick and free way to change your IP address.
- Best VPN service provider. Anonymous, fast and cheap VPN service - Whoer VPN. Servers in 16 countries, secure and fast connection speed, good for blocked websites, online support.
- Attributes
- Implements
Examples
The following code example assigns a WebProxy instance to a WebRequest instance. The WebRequest instance uses the proxy to connect to external Internet resources. (For an example that demonstrates using the WPAD feature, see the documentation for the IWebProxyScript class.)
Remarks
The WebProxy class contains the proxy settings that WebRequest instances use to determine whether a Web proxy is used to send requests. Global Web proxy settings can be specified in machine and application configuration files, and applications can use instances of the WebProxy class to customize Web proxy use. The WebProxy class is the base implementation of the IWebProxy interface.
To obtain instances of the Web proxy class, you can use any of the following methods:
The WebProxy constructor.
The GetDefaultProxy method.
The Select method.
These methods each supply a WebProxy instance that you can further customize; the difference between them is how the instance is initialized before it is returned to your application. The WebProxy constructor returns an instance of the WebProxy class with the Address property set to null
. When a request uses a WebProxy instance in this state, no proxy is used to send the request.
The GetDefaultProxy method returns an instance of the WebProxy class with the Address, BypassProxyOnLocal, and BypassList properties set to the values used by Internet Explorer 5.5 and later.
The Select method returns an instance of the WebProxy class with it properties set according to a combination of Internet Explorer and configuration file settings.
The WebProxy class supports automatic detection and execution of proxy configuration scripts. This feature is also known as Web Proxy Auto-Discovery (WPAD). When using automatic proxy configuration, a configuration script, typically named Wpad.dat, must be located, downloaded, compiled, and run. If these operations are successful, the script returns the proxies that can be used for a request.
Constructors
WebProxy() | Initializes an empty instance of the WebProxy class. |
WebProxy(SerializationInfo, StreamingContext) | Initializes an instance of the WebProxy class using previously serialized content. |
WebProxy(String) | Initializes a new instance of the WebProxy class with the specified URI. |
WebProxy(String, Boolean) | Initializes a new instance of the WebProxy class with the specified URI and bypass setting. |
WebProxy(String, Boolean, String[]) | Initializes a new instance of the WebProxy class with the specified URI, bypass setting, and list of URIs to bypass. |
WebProxy(String, Boolean, String[], ICredentials) | Initializes a new instance of the WebProxy class with the specified URI, bypass setting, list of URIs to bypass, and credentials. |
WebProxy(String, Int32) | Initializes a new instance of the WebProxy class with the specified host and port number. |
WebProxy(Uri) | Initializes a new instance of the WebProxy class from the specified Uri instance. |
WebProxy(Uri, Boolean) | Initializes a new instance of the WebProxy class with the Uri instance and bypass setting. |
WebProxy(Uri, Boolean, String[]) | Initializes a new instance of the WebProxy class with the specified Uri instance, bypass setting, and list of URIs to bypass. |
WebProxy(Uri, Boolean, String[], ICredentials) | Initializes a new instance of the WebProxy class with the specified Uri instance, bypass setting, list of URIs to bypass, and credentials. |
Properties
Address | Gets or sets the address of the proxy server. |
BypassArrayList | Gets a list of addresses that do not use the proxy server. |
BypassList | Gets or sets an array of addresses that do not use the proxy server. |
BypassProxyOnLocal | Gets or sets a value that indicates whether to bypass the proxy server for local addresses. |
Credentials | Gets or sets the credentials to submit to the proxy server for authentication. |
UseDefaultCredentials | Gets or sets a Boolean value that controls whether the DefaultCredentials are sent with requests. |
Methods
CreateDefaultProxy() | |
Equals(Object) | Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetDefaultProxy() | Obsolete. Reads the Internet Explorer nondynamic proxy settings. |
GetHashCode() | Serves as the default hash function. (Inherited from Object) |
GetObjectData(SerializationInfo, StreamingContext) | Populates a SerializationInfo with the data that is needed to serialize the target object. |
GetProxy(Uri) | Returns the proxied URI for a request. |
GetType() | Gets the Type of the current instance. (Inherited from Object) |
IsBypassed(Uri) | Indicates whether to use the proxy server for the specified host. |
MemberwiseClone() | Creates a shallow copy of the current Object. (Inherited from Object) |
ToString() | Returns a string that represents the current object. (Inherited from Object) |
Explicit Interface Implementations
ISerializable.GetObjectData(SerializationInfo, StreamingContext) | Creates the serialization data and context that are used by the system to serialize a WebProxy object. |
Applies to
-->Definition
Gets or sets a Boolean value that controls whether the DefaultCredentials are sent with requests.
Property Value
- Boolean
true
if the default credentials are used; otherwise, false
. The default value is false
.
Exceptions
You attempted to set this property when the Credentials property contains credentials other than the default credentials.
Remarks
Set this property to true
when requests made by this WebProxy object should, if requested by the server, be authenticated using the credentials of the currently logged on user. For client applications, this is the desired behavior in most scenarios. For middle tier applications, such as ASP.NET applications, instead of using this property, you would typically set the Credentials property to the credentials of the client on whose behalf the request is made.
The following table shows the effect of setting the UseDefaultCredentials value, based on the value of the Credentials property.
Definition
Gets or sets a Boolean value that controls whether the DefaultCredentials are sent with requests.
Property Value
- Boolean
true
if the default credentials are used; otherwise, false
. The default value is false
.
Exceptions
You attempted to set this property when the Credentials property contains credentials other than the default credentials.
Remarks
Set this property to true
when requests made by this WebProxy object should, if requested by the server, be authenticated using the credentials of the currently logged on user. For client applications, this is the desired behavior in most scenarios. For middle tier applications, such as ASP.NET applications, instead of using this property, you would typically set the Credentials property to the credentials of the client on whose behalf the request is made.
The following table shows the effect of setting the UseDefaultCredentials value, based on the value of the Credentials property.
System.net.webproxy Getdefaultproxy()
Credentials value | UseDefaultCredentials value | Effect |
---|---|---|
DefaultCredentials | true | No effect. |
DefaultCredentials | false | Credentials is set to null . |
null | true | Credentials is set to DefaultCredentials. |
Any value other than DefaultCredentials or null | true or false | Setting UseDefaultCredentials throws an exception. |
Webproxy.net Chrome
If UseDefaultCredentials is false
, you can change the Credentials property to any credentials. If UseDefaultCredentials is true
, changing the Credentials property from DefaultCredentials (the value that is set when the UseDefaultCredentials property is set to true
) will throw an exception.