WebProxy 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 WebProxy 類別的新執行個體。
多載
| 名稱 | Description |
|---|---|
| WebProxy() |
初始化類別的 WebProxy 空實例。 |
| WebProxy(String, Boolean, String[], ICredentials) |
初始化一個新實例 WebProxy ,使用指定的 URI、繞過設定、可繞過的 URI 清單及憑證。 |
| WebProxy(Uri, Boolean, String[]) | |
| WebProxy(String, Boolean, String[]) |
初始化一個新的類別實例 WebProxy ,並設定指定的 URI、繞過設定及可繞過的 URI 清單。 |
| WebProxy(Uri, Boolean) | |
| WebProxy(Uri, Boolean, String[], ICredentials) | |
| WebProxy(String, Boolean) |
初始化一個新的類別實例 WebProxy ,並使用指定的 URI 與繞過設定。 |
| WebProxy(SerializationInfo, StreamingContext) |
已淘汰.
利用先前序列化的內容初始化類別實 WebProxy 例。 |
| WebProxy(Uri) | |
| WebProxy(String) |
初始化一個新的類別實例 WebProxy ,使用指定的 URI。 |
| WebProxy(String, Int32) |
初始化一個以指定主機與埠號的新類別實例 WebProxy 。 |
WebProxy()
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
初始化類別的 WebProxy 空實例。
public:
WebProxy();
public WebProxy();
Public Sub New ()
範例
以下程式碼範例示範呼叫此建構子。
public static WebProxy CreateProxy()
{
return new WebProxy();
}
備註
無參數建構子會初始化一個空的類別實例 WebProxy ,屬性 Address 設為 null。
當屬性 Address 為 null時,方法 IsBypassed 回傳 true ,而方法 GetProxy 回傳目的地址。
適用於
WebProxy(String, Boolean, String[], ICredentials)
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
初始化一個新實例 WebProxy ,使用指定的 URI、繞過設定、可繞過的 URI 清單及憑證。
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);
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)
參數
- Address
- String
代理伺服器的 URI。
- BypassOnLocal
- Boolean
true以繞過本地位址的代理;否則,。 false
- BypassList
- String[]
一個包含伺服器 URI 的正則表達式字串陣列,要繞過。
- Credentials
- ICredentials
一個 ICredentials 提交給代理伺服器進行驗證的實例。
例外狀況
Address 是一個無效的 URI。
範例
以下程式碼範例示範呼叫此建構子。
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);
}
備註
該WebProxy實例初始化時,屬性Address設Uri為包含 Address,BypassProxyOnLocal該屬性為 BypassOnLocal,屬性為 ,BypassList屬性為 BypassList,屬性為 Credentials。Credentials
另請參閱
適用於
WebProxy(Uri, Boolean, String[])
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
public:
WebProxy(Uri ^ Address, bool BypassOnLocal, cli::array <System::String ^> ^ BypassList);
public WebProxy(Uri? Address, bool BypassOnLocal, 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())
參數
- BypassOnLocal
- Boolean
true以繞過本地位址的代理;否則,。 false
- BypassList
- String[]
一個包含伺服器 URI 的正則表達式字串陣列,要繞過。
範例
以下程式碼範例示範呼叫此建構子。
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);
}
備註
實 WebProxy 例初始化時屬性 Address 設 Address為 , BypassProxyOnLocal 屬性設為 BypassOnLocal,屬性設為 , BypassList 屬性設為 BypassList。
適用於
WebProxy(String, Boolean, String[])
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
初始化一個新的類別實例 WebProxy ,並設定指定的 URI、繞過設定及可繞過的 URI 清單。
public:
WebProxy(System::String ^ Address, bool BypassOnLocal, cli::array <System::String ^> ^ BypassList);
public WebProxy(string? Address, bool BypassOnLocal, 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())
參數
- Address
- String
代理伺服器的 URI。
- BypassOnLocal
- Boolean
true以繞過本地位址的代理;否則,。 false
- BypassList
- String[]
一組正則表達式字串陣列,包含要繞過伺服器的 URI。
例外狀況
Address 是一個無效的 URI。
範例
以下程式碼範例示範呼叫此建構子。
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);
}
備註
該 WebProxy 實例初始化時,屬性 Address 設 Uri 為包含 Address的實例,屬性 BypassProxyOnLocal 設為 BypassOnLocal,屬性 BypassList 設為 ,屬性設為 BypassList。
另請參閱
適用於
WebProxy(Uri, Boolean)
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
public:
WebProxy(Uri ^ Address, bool BypassOnLocal);
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)
參數
- BypassOnLocal
- Boolean
true以繞過本地位址的代理;否則,。 false
範例
以下程式碼範例示範呼叫此建構子。
public static WebProxy CreateProxyWithExampleAddress(bool bypassLocal)
{
return new WebProxy(new Uri("http://contoso"), bypassLocal);
}
備註
實WebProxy例初始化時屬性Address設為 ,AddressBypassProxyOnLocal屬性設BypassOnLocal為 。
適用於
WebProxy(Uri, Boolean, String[], ICredentials)
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
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);
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)
參數
- BypassOnLocal
- Boolean
true以繞過本地位址的代理;否則,。 false
- BypassList
- String[]
一個包含伺服器 URI 的正則表達式字串陣列,要繞過。
- Credentials
- ICredentials
一個 ICredentials 提交給代理伺服器進行驗證的實例。
範例
以下程式碼範例示範呼叫此建構子。
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);
}
備註
WebProxy實例初始化時屬性Address設為 Address,BypassProxyOnLocal屬性設BypassOnLocal為 ,屬性設為 ,BypassList屬性設為 BypassList,Credentials屬性設Credentials為 。
適用於
WebProxy(String, Boolean)
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
初始化一個新的類別實例 WebProxy ,並使用指定的 URI 與繞過設定。
public:
WebProxy(System::String ^ Address, bool BypassOnLocal);
public WebProxy(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)
參數
- Address
- String
代理伺服器的 URI。
- BypassOnLocal
- Boolean
true以繞過本地位址的代理;否則,。 false
例外狀況
Address 是一個無效的 URI。
範例
以下程式碼範例示範呼叫此建構子。
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;
}
備註
該 WebProxy 實例初始化時,屬性 Address 設 Uri 為包含 Address 的實例,屬性 BypassProxyOnLocal 設為 BypassOnLocal。
另請參閱
適用於
WebProxy(SerializationInfo, StreamingContext)
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
警告
This API supports obsolete formatter-based serialization. It should not be called or extended by application code.
利用先前序列化的內容初始化類別實 WebProxy 例。
protected:
WebProxy(System::Runtime::Serialization::SerializationInfo ^ serializationInfo, System::Runtime::Serialization::StreamingContext streamingContext);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
protected WebProxy(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext);
protected WebProxy(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext);
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Net.WebProxy : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Net.WebProxy
new System.Net.WebProxy : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Net.WebProxy
Protected Sub New (serializationInfo As SerializationInfo, streamingContext As StreamingContext)
參數
- serializationInfo
- SerializationInfo
序列化資料。
- streamingContext
- StreamingContext
序列化資料的背景。
- 屬性
備註
系統呼叫此方法來反序列化實 WebProxy 例;應用程式不會呼叫此方法。
適用於
WebProxy(Uri)
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
public:
WebProxy(Uri ^ Address);
public WebProxy(Uri? Address);
public WebProxy(Uri Address);
new System.Net.WebProxy : Uri -> System.Net.WebProxy
Public Sub New (Address As Uri)
參數
範例
以下程式碼範例示範呼叫此建構子。
public static WebProxy CreateProxyWithExampleAddress()
{
return new WebProxy(new Uri("http://contoso"));
}
備註
該 WebProxy 實例初始化時,屬性 Address 設定為參數 Address 。
適用於
WebProxy(String)
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
初始化一個新的類別實例 WebProxy ,使用指定的 URI。
public:
WebProxy(System::String ^ Address);
public WebProxy(string? Address);
public WebProxy(string Address);
new System.Net.WebProxy : string -> System.Net.WebProxy
Public Sub New (Address As String)
參數
- Address
- String
代理伺服器的 URI。
例外狀況
Address 是一個無效的 URI。
範例
以下程式碼範例示範呼叫此建構子。
public static WebProxy CreateProxyWithHost()
{
return new WebProxy("http://contoso");
}
備註
該 WebProxy 實例初始化時,屬性 Address 設定為 Uri 包含 Address的實例。
適用於
WebProxy(String, Int32)
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
- 來源:
- WebProxy.cs
初始化一個以指定主機與埠號的新類別實例 WebProxy 。
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)
參數
- Host
- String
代理主機的名字。
- Port
- Int32
輸入 Host 埠號以供使用。
例外狀況
由 和 合併HostPort形成的 URI 並非有效的 URI。
範例
以下程式碼範例示範呼叫此建構子。
public static WebProxy CreateProxyWithHostAndPort()
{
return new WebProxy("contoso", 80);
}
備註
該 WebProxy 實例以 屬性初始 Address 化,實 Uri 例形式為 http:// Host : Port。