Table of Contents

Class WebProxy

Namespace
System.Net
Assembly
System.Net.Http.dll

Contains HTTP proxy settings for the WebRequest class.

public class WebProxy : IWebProxy
Inheritance
WebProxy
Implements
Inherited Members
Extension Methods

Constructors

WebProxy()

Initializes an empty instance of the WebProxy class.

public WebProxy()

Remarks

The URI of the proxy can be set later, using the Address property.

WebProxy(string)

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

public WebProxy(string Address)

Parameters

Address string

The URI address of the proxy server.

Remarks

The WebProxy instance is initialized with the Address property set to a Uri instance containing the Address string.

For the new instance of the WebProxy class, "Bypass on local addresses" is set to false.

WebProxy(string, bool)

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

public WebProxy(string Address, bool BypassOnLocal)

Parameters

Address string

The URI of the proxy server.

BypassOnLocal bool

Indicates whether to bypass the proxy when accessing local addresses.

WebProxy(string, int)

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

public WebProxy(string Host, int Port)

Parameters

Host string

The name of the proxy host, such as: contoso

Port int

The port number on the host to use, such as: 80

Remarks

The WebProxy instance is initialized with the Address property set to a Uri instance of the form: http://Host:Port

WebProxy(Uri)

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

public WebProxy(Uri Address)

Parameters

Address Uri

A Uri instance that contains the address of the proxy server.

WebProxy(Uri, bool)

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

public WebProxy(Uri Address, bool BypassOnLocal)

Parameters

Address Uri

A Uri instance that contains the address of the proxy server.

BypassOnLocal bool

Indicates whether to bypass the WebProxy on local network addresses.

Properties

Address

Gets or sets the address of the proxy server.

public Uri Address { get; set; }

Property Value

Uri

A Uri instance that contains the address of the proxy server.

BypassProxyOnLocal

Gets or sets whether to bypass the proxy server for local addresses.

public bool BypassProxyOnLocal { get; set; }

Property Value

bool

true to bypass the proxy server for local addresses; otherwise, false.

Methods

GetProxy(Uri)

Returns the proxied URI for a request.

public Uri GetProxy(Uri destination)

Parameters

destination Uri

The Uri instance of the requested Internet resource.

Returns

Uri

The Uri instance of the Internet resource, if the resource is on the bypass list; otherwise, the Uri instance of the proxy.

IsBypassed(Uri)

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

public bool IsBypassed(Uri host)

Parameters

host Uri

The Uri instance of the host to check for proxy use.

Returns

bool

true if the proxy server should not be used for the host; otherwise, false.