WebProxy Constructor (String, Int32)


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

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

public WebProxy(
	string Host,
	int Port


Type: System.String

The name of the proxy host.

Type: System.Int32

The port number on Host to use.

Exception Condition

The URI formed by combining Host and Port is not a valid URI.

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

The following code example demonstrates calling this constructor.

public static WebProxy CreateProxyWithHostAndPort()
    return new WebProxy("http://contoso", 80);

.NET Framework
Available since 1.1
Return to top