共用方式為


HttpWebClientProtocol.Proxy 屬性

定義

透過防火牆取得或設定代理資訊,以發送 XML 網路服務請求。

public:
 property System::Net::IWebProxy ^ Proxy { System::Net::IWebProxy ^ get(); void set(System::Net::IWebProxy ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Net.IWebProxy Proxy { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.Proxy : System.Net.IWebProxy with get, set
Public Property Proxy As IWebProxy

屬性值

其中有 IWebProxy 代理資訊,用於透過防火牆發出請求。 預設值是作業系統代理設定。

屬性

範例

以下範例在呼叫 Math XML Web 服務前設定以下代理伺服器:代理伺服器 http://proxyserver至 ,代理埠設為 80,以及繞過代理伺服器以處理本地位址。

MyMath::Math^ math = gcnew MyMath::Math;

// Set the proxy server to proxyserver, set the port to 80, and specify to bypass the proxy server
// for local addresses.
IWebProxy^ proxyObject = gcnew WebProxy( "http://proxyserver:80",true );
math->Proxy = proxyObject;

// Call the Add XML Web service method.
int total = math->Add( 8, 5 );

MyMath.Math math = new MyMath.Math();

// Set the proxy server to proxyserver, set the port to 80, and specify to bypass the proxy server
// for local addresses.
IWebProxy proxyObject = new WebProxy("http://proxyserver:80", true);
math.Proxy = proxyObject;

// Call the Add XML Web service method.
int total = math.Add(8, 5);
Dim math As New MyMath.Math()

' Set the proxy server to proxyserver, set the port to 80, and specify
' to bypass the proxy server for local addresses.
Dim proxyObject As New WebProxy("http://proxyserver:80", True)
math.Proxy = proxyObject

' Call the Add XML Web service method.
Dim total As Integer = math.Add(8, 5)

備註

如果客戶端需要使用與系統設定不同的代理設定,請使用該 Proxy 屬性。 用這個 WebProxy 類別來設定代理設定,因為它實 IWebProxy作了 。

預設代理設定可以在設定檔中設定。 詳情請參閱 「網路應用程式配置」。

適用於

另請參閱