WebProxy WebProxy WebProxy WebProxy Constructors

Definition

Overloads

WebProxy() WebProxy() WebProxy()

Initializes an empty instance of the WebProxy class.

WebProxy(String) WebProxy(String) WebProxy(String) WebProxy(String)

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

WebProxy(Uri) WebProxy(Uri) WebProxy(Uri) WebProxy(Uri)

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

WebProxy(SerializationInfo, StreamingContext) WebProxy(SerializationInfo, StreamingContext) WebProxy(SerializationInfo, StreamingContext)

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

WebProxy(String, Boolean) WebProxy(String, Boolean) WebProxy(String, Boolean) WebProxy(String, Boolean)

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

WebProxy(String, Int32) WebProxy(String, Int32) WebProxy(String, Int32) WebProxy(String, Int32)

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

WebProxy(Uri, Boolean) WebProxy(Uri, Boolean) WebProxy(Uri, Boolean) WebProxy(Uri, Boolean)

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

WebProxy(String, Boolean, String[]) WebProxy(String, Boolean, String[]) WebProxy(String, Boolean, String[]) 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(Uri, Boolean, String[]) WebProxy(Uri, Boolean, String[]) WebProxy(Uri, Boolean, String[]) 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(String, Boolean, String[], ICredentials) WebProxy(String, Boolean, String[], ICredentials) WebProxy(String, Boolean, String[], ICredentials) 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(Uri, Boolean, String[], ICredentials) WebProxy(Uri, Boolean, String[], ICredentials) WebProxy(Uri, Boolean, String[], ICredentials) 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.

WebProxy() WebProxy() WebProxy()

Initializes an empty instance of the WebProxy class.

public:
 WebProxy();
public WebProxy ();
Public Sub New ()

Examples

The following code example demonstrates calling this constructor.

WebProxy^ CreateProxy()
{
   return gcnew WebProxy;
}
public static WebProxy CreateProxy()
{
    return new WebProxy();
}

Remarks

The parameterless constructor initializes an empty instance of the WebProxy class with the Address property set to null.

When the Address property is null, the IsBypassed method returns true and the GetProxy method returns the destination address.

WebProxy(String) WebProxy(String) WebProxy(String) WebProxy(String)

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

public:
 WebProxy(System::String ^ Address);
public WebProxy (string Address);
new System.Net.WebProxy : string -> System.Net.WebProxy
Public Sub New (Address As String)

Parameters

Address
String String String String

The URI of the proxy server.

Exceptions

Examples

The following code example demonstrates calling this constructor.

WebProxy^ CreateProxyWithHost()
{
   return gcnew WebProxy( "http://contoso" );
}
public static WebProxy CreateProxyWithHost()
{
    return new WebProxy("http://contoso");
}

Remarks

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

WebProxy(Uri) WebProxy(Uri) WebProxy(Uri) WebProxy(Uri)

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

public:
 WebProxy(Uri ^ Address);
public WebProxy (Uri Address);
new System.Net.WebProxy : Uri -> System.Net.WebProxy
Public Sub New (Address As Uri)

Parameters

Address
Uri Uri Uri Uri

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

Examples

The following code example demonstrates calling this constructor.

WebProxy^ CreateProxyWithExampleAddress()
{
   return gcnew WebProxy( gcnew Uri( "http://contoso" ) );
}
public static WebProxy CreateProxyWithExampleAddress()
{
    return new WebProxy(new Uri("http://contoso"));
}

Remarks

The WebProxy instance is initialized with the Address property set to the Address parameter.

WebProxy(SerializationInfo, StreamingContext) WebProxy(SerializationInfo, StreamingContext) WebProxy(SerializationInfo, StreamingContext)

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

protected:
 WebProxy(System::Runtime::Serialization::SerializationInfo ^ serializationInfo, System::Runtime::Serialization::StreamingContext streamingContext);
protected WebProxy (System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext);
new System.Net.WebProxy : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Net.WebProxy

Parameters

serializationInfo
SerializationInfo SerializationInfo SerializationInfo SerializationInfo

The serialization data.

streamingContext
StreamingContext StreamingContext StreamingContext StreamingContext

The context for the serialized data.

Remarks

This method is called by the system to deserialize a WebProxy instance; applications do not call it.

WebProxy(String, Boolean) WebProxy(String, Boolean) WebProxy(String, Boolean) WebProxy(String, Boolean)

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

public:
 WebProxy(System::String ^ Address, bool BypassOnLocal);
public WebProxy (string Address, bool BypassOnLocal);
new System.Net.WebProxy : string * bool -> System.Net.WebProxy
Public Sub New (Address As String, BypassOnLocal As Boolean)

Parameters

Address
String String String String

The URI of the proxy server.

BypassOnLocal
Boolean Boolean Boolean Boolean

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

Exceptions

Examples

The following code example demonstrates calling this constructor.

WebProxy^ CreateProxyWithHostAddress( bool bypassLocal )
{
   WebProxy^ proxy = gcnew WebProxy( "http://contoso",bypassLocal );
   Console::WriteLine( "Bypass proxy for local URIs?: {0}", 
      proxy->BypassProxyOnLocal );
   return proxy;
}
public static WebProxy CreateProxyWithHostAddress(bool bypassLocal)
{
    WebProxy proxy =  new WebProxy("http://contoso", bypassLocal);
    Console.WriteLine("Bypass proxy for local URIs?: {0}", 
       proxy.BypassProxyOnLocal);
    return proxy;
}

Remarks

The WebProxy instance is initialized with the Address property set to a Uri instance that contains Address and the BypassProxyOnLocal property set to BypassOnLocal.

See also

WebProxy(String, Int32) WebProxy(String, Int32) WebProxy(String, Int32) WebProxy(String, Int32)

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

public:
 WebProxy(System::String ^ Host, int Port);
public WebProxy (string Host, int Port);
new System.Net.WebProxy : string * int -> System.Net.WebProxy
Public Sub New (Host As String, Port As Integer)

Parameters

Host
String String String String

The name of the proxy host.

Port
Int32 Int32 Int32 Int32

The port number on Host to use.

Exceptions

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

Examples

The following code example demonstrates calling this constructor.

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

Remarks

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

WebProxy(Uri, Boolean) WebProxy(Uri, Boolean) WebProxy(Uri, Boolean) WebProxy(Uri, Boolean)

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

public:
 WebProxy(Uri ^ Address, bool BypassOnLocal);
public WebProxy (Uri Address, bool BypassOnLocal);
new System.Net.WebProxy : Uri * bool -> System.Net.WebProxy
Public Sub New (Address As Uri, BypassOnLocal As Boolean)

Parameters

Address
Uri Uri Uri Uri

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

BypassOnLocal
Boolean Boolean Boolean Boolean

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

Examples

The following code example demonstrates calling this constructor.

WebProxy^ CreateProxyWithExampleAddress( bool bypassLocal )
{
   return gcnew WebProxy( gcnew Uri( "http://contoso" ), bypassLocal );
}
public static WebProxy CreateProxyWithExampleAddress(bool bypassLocal)
{
    return new WebProxy(new Uri("http://contoso"), bypassLocal);
}

Remarks

The WebProxy instance is initialized with the Address property set to Address and with the BypassProxyOnLocal property set to BypassOnLocal.

WebProxy(String, Boolean, String[]) WebProxy(String, Boolean, String[]) WebProxy(String, Boolean, String[]) WebProxy(String, Boolean, String[])

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

public:
 WebProxy(System::String ^ Address, bool BypassOnLocal, cli::array <System::String ^> ^ BypassList);
public WebProxy (string Address, bool BypassOnLocal, string[] BypassList);
new System.Net.WebProxy : string * bool * string[] -> System.Net.WebProxy
Public Sub New (Address As String, BypassOnLocal As Boolean, BypassList As String())

Parameters

Address
String String String String

The URI of the proxy server.

BypassOnLocal
Boolean Boolean Boolean Boolean

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

BypassList
String[]

An array of regular expression strings that contain the URIs of the servers to bypass.

Exceptions

Examples

The following code example demonstrates calling this constructor.

WebProxy^ CreateProxyWithHostAndBypassList( bool bypassLocal )
{
   // Do not use the proxy server for Contoso.com URIs.
   array<String^>^ bypassList = {";*.Contoso.com"};
   return gcnew WebProxy( "http://contoso",
      bypassLocal,
      bypassList );
}
public static WebProxy CreateProxyWithHostAndBypassList(bool bypassLocal)
{
    // Do not use the proxy server for Contoso.com URIs.
    string[] bypassList = new string[]{";*.Contoso.com"};
    return new WebProxy("http://contoso", 
        bypassLocal, 
        bypassList);
}

Remarks

The WebProxy instance is initialized with the Address property set to a Uri instance that contains Address, the BypassProxyOnLocal property set to BypassOnLocal, and the BypassList property set to BypassList.

See also

WebProxy(Uri, Boolean, String[]) WebProxy(Uri, Boolean, String[]) WebProxy(Uri, Boolean, String[]) 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.

public:
 WebProxy(Uri ^ Address, bool BypassOnLocal, cli::array <System::String ^> ^ BypassList);
public WebProxy (Uri Address, bool BypassOnLocal, string[] BypassList);
new System.Net.WebProxy : Uri * bool * string[] -> System.Net.WebProxy
Public Sub New (Address As Uri, BypassOnLocal As Boolean, BypassList As String())

Parameters

Address
Uri Uri Uri Uri

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

BypassOnLocal
Boolean Boolean Boolean Boolean

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

BypassList
String[]

An array of regular expression strings that contains the URIs of the servers to bypass.

Examples

The following code example demonstrates calling this constructor.

WebProxy^ CreateProxyWithBypassList( bool bypassLocal )
{
   // Do not use the proxy server for Contoso.com URIs.
   array<String^>^ bypassList = {";*.Contoso.com"};
   return gcnew WebProxy( gcnew Uri( "http://contoso" ),
      bypassLocal,
      bypassList );
}
public static WebProxy CreateProxyWithBypassList(bool bypassLocal)
{
    // Do not use the proxy server for Contoso.com URIs.
    string[] bypassList = new string[]{";*.Contoso.com"};
    return new WebProxy(new Uri("http://contoso"), 
        bypassLocal, 
        bypassList);
}

Remarks

The WebProxy instance is initialized with the Address property set to Address, the BypassProxyOnLocal property set to BypassOnLocal, and the BypassList property set to BypassList.

WebProxy(String, Boolean, String[], ICredentials) WebProxy(String, Boolean, String[], ICredentials) WebProxy(String, Boolean, String[], ICredentials) 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.

public:
 WebProxy(System::String ^ Address, bool BypassOnLocal, cli::array <System::String ^> ^ BypassList, System::Net::ICredentials ^ Credentials);
public WebProxy (string Address, bool BypassOnLocal, string[] BypassList, System.Net.ICredentials Credentials);
new System.Net.WebProxy : string * bool * string[] * System.Net.ICredentials -> System.Net.WebProxy
Public Sub New (Address As String, BypassOnLocal As Boolean, BypassList As String(), Credentials As ICredentials)

Parameters

Address
String String String String

The URI of the proxy server.

BypassOnLocal
Boolean Boolean Boolean Boolean

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

BypassList
String[]

An array of regular expression strings that contains the URIs of the servers to bypass.

Credentials
ICredentials ICredentials ICredentials ICredentials

An ICredentials instance to submit to the proxy server for authentication.

Exceptions

Examples

The following code example demonstrates calling this constructor.

WebProxy^ CreateProxyWithCredentials( bool bypassLocal )
{
   // Do not use the proxy server for Contoso.com URIs.
   array<String^>^ bypassList = {";*.Contoso.com"};
   return gcnew WebProxy( "http://contoso",
      bypassLocal,
      bypassList,
      CredentialCache::DefaultCredentials );
}
public static WebProxy CreateProxyWithCredentials(bool bypassLocal)
{
    // Do not use the proxy server for Contoso.com URIs.
    string[] bypassList = new string[]{";*.Contoso.com"};
    return new WebProxy("http://contoso", 
        bypassLocal, 
        bypassList,
        CredentialCache.DefaultCredentials);
}

Remarks

The WebProxy instance is initialized with the Address property set to a Uri instance that contains Address, the BypassProxyOnLocal property set to BypassOnLocal, the BypassList property set to BypassList, and the Credentials property set to Credentials.

See also

WebProxy(Uri, Boolean, String[], ICredentials) WebProxy(Uri, Boolean, String[], ICredentials) WebProxy(Uri, Boolean, String[], ICredentials) 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.

public:
 WebProxy(Uri ^ Address, bool BypassOnLocal, cli::array <System::String ^> ^ BypassList, System::Net::ICredentials ^ Credentials);
public WebProxy (Uri Address, bool BypassOnLocal, string[] BypassList, System.Net.ICredentials Credentials);
new System.Net.WebProxy : Uri * bool * string[] * System.Net.ICredentials -> System.Net.WebProxy
Public Sub New (Address As Uri, BypassOnLocal As Boolean, BypassList As String(), Credentials As ICredentials)

Parameters

Address
Uri Uri Uri Uri

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

BypassOnLocal
Boolean Boolean Boolean Boolean

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

BypassList
String[]

An array of regular expression strings that contains the URIs of the servers to bypass.

Credentials
ICredentials ICredentials ICredentials ICredentials

An ICredentials instance to submit to the proxy server for authentication.

Examples

The following code example demonstrates calling this constructor.

WebProxy^ CreateProxyWithCredentials2( bool bypassLocal )
{
   
   // Do not use the proxy server for Contoso.com URIs.
   array<String^>^ bypassList = {";*.Contoso.com"};
   return gcnew WebProxy( gcnew Uri( "http://contoso" ),
      bypassLocal,
      bypassList,
      CredentialCache::DefaultCredentials );
}
public static WebProxy CreateProxyWithCredentials2(bool bypassLocal)
{
    // Do not use the proxy server for Contoso.com URIs.
    string[] bypassList = new string[]{";*.Contoso.com"};
    return new WebProxy(new Uri("http://contoso"), 
        bypassLocal, 
        bypassList,
        CredentialCache.DefaultCredentials);
}

Remarks

The WebProxy instance is initialized with the Address property set to Address, the BypassProxyOnLocal property set to BypassOnLocal, the BypassList property set to BypassList, and the Credentials property set to Credentials.

Applies to