TechNet
Export (0) Print
Expand All

WebProxy Class

 

Contains HTTP proxy settings for the WebRequest class.

Namespace:   System.Net
Assembly:  System (in System.dll)

System.Object
  System.Net.WebProxy

[SerializableAttribute]
public class WebProxy : IWebProxy, ISerializable

NameDescription
System_CAPS_pubmethodWebProxy()

Initializes an empty instance of the WebProxy class.

System_CAPS_protmethodWebProxy(SerializationInfo, StreamingContext)

Initializes an instance of the WebProxy class using previously serialized content.

System_CAPS_pubmethodWebProxy(String)

Initializes a new instance of the WebProxy class with the specified URI.

System_CAPS_pubmethodWebProxy(String, Boolean)

Initializes a new instance of the WebProxy class with the specified URI and bypass setting.

System_CAPS_pubmethodWebProxy(String, Boolean, String[])

Initializes a new instance of the WebProxy class with the specified URI, bypass setting, and list of URIs to bypass.

System_CAPS_pubmethodWebProxy(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.

System_CAPS_pubmethodWebProxy(String, Int32)

Initializes a new instance of the WebProxy class with the specified host and port number.

System_CAPS_pubmethodWebProxy(Uri)

Initializes a new instance of the WebProxy class from the specified Uri instance.

System_CAPS_pubmethodWebProxy(Uri, Boolean)

Initializes a new instance of the WebProxy class with the Uri instance and bypass setting.

System_CAPS_pubmethodWebProxy(Uri, Boolean, String[])

Initializes a new instance of the WebProxy class with the specified Uri instance, bypass setting, and list of URIs to bypass.

System_CAPS_pubmethodWebProxy(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.

NameDescription
System_CAPS_pubpropertyAddress

Gets or sets the address of the proxy server.

System_CAPS_pubpropertyBypassArrayList

Gets a list of addresses that do not use the proxy server.

System_CAPS_pubpropertyBypassList

Gets or sets an array of addresses that do not use the proxy server.

System_CAPS_pubpropertyBypassProxyOnLocal

Gets or sets a value that indicates whether to bypass the proxy server for local addresses.

System_CAPS_pubpropertyCredentials

Gets or sets the credentials to submit to the proxy server for authentication.

System_CAPS_pubpropertyUseDefaultCredentials

Gets or sets a Boolean value that controls whether the DefaultCredentials are sent with requests.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticGetDefaultProxy()

Obsolete.Reads the Internet Explorer nondynamic proxy settings.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_protmethodGetObjectData(SerializationInfo, StreamingContext)

Populates a SerializationInfo with the data that is needed to serialize the target object.

System_CAPS_pubmethodGetProxy(Uri)

Returns the proxied URI for a request.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodIsBypassed(Uri)

Indicates whether to use the proxy server for the specified host.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodISerializable.GetObjectData(SerializationInfo, StreamingContext)

This API supports the product infrastructure and is not intended to be used directly from your code. Creates the serialization data and context that are used by the system to serialize a WebProxy object.

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:

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.

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.)

WebProxy proxyObject = new WebProxy("http://proxyserver:80/",true);
WebRequest req = WebRequest.Create("http://www.contoso.com");
req.Proxy = proxyObject;

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft