WebProxy WebProxy WebProxy WebProxy Class

定義

包含 WebRequest 類別的 HTTP Proxy 設定。Contains HTTP proxy settings for the WebRequest class.

public ref class WebProxy : System::Runtime::Serialization::ISerializable
[System.Serializable]
public class WebProxy : System.Runtime.Serialization.ISerializable
type WebProxy = class
    interface ISerializable
    interface IWebProxy
Public Class WebProxy
Implements ISerializable
繼承
WebProxyWebProxyWebProxyWebProxy
屬性
實作

範例

下列程式碼範例會將WebProxy實例指派WebRequest給實例。The following code example assigns a WebProxy instance to a WebRequest instance. WebRequest實例會使用 proxy 連接到外部網際網路資源。The WebRequest instance uses the proxy to connect to external Internet resources. (如需示範使用 WPAD 功能的範例, 請參閱IWebProxyScript類別的檔。)(For an example that demonstrates using the WPAD feature, see the documentation for the IWebProxyScript class.)

WebProxy^ proxyObject = gcnew WebProxy( "http://proxyserver:80/",true );
WebRequest^ req = WebRequest::Create( "http://www.contoso.com" );
req->Proxy = proxyObject;
WebProxy proxyObject = new WebProxy("http://proxyserver:80/",true);
WebRequest req = WebRequest.Create("http://www.contoso.com");
req.Proxy = proxyObject;

Dim proxyObject As New WebProxy("http://proxyserver:80/", True)
Dim req As WebRequest = WebRequest.Create("http://www.contoso.com")
req.Proxy = proxyObject

備註

類別包含 proxy 設定, WebRequest供實例用來判斷是否使用 Web proxy 來傳送要求。 WebProxyThe WebProxy class contains the proxy settings that WebRequest instances use to determine whether a Web proxy is used to send requests. 您可以在電腦和應用程式佈建檔中指定全域 Web proxy 設定, 而應用程式可以使用WebProxy類別的實例來自訂 Web proxy 使用。Global Web proxy settings can be specified in machine and application configuration files, and applications can use instances of the WebProxy class to customize Web proxy use. 類別是IWebProxy介面的基底執行。 WebProxyThe WebProxy class is the base implementation of the IWebProxy interface.

若要取得 Web proxy 類別的實例, 您可以使用下列任何一種方法:To obtain instances of the Web proxy class, you can use any of the following methods:

這些方法各自提供WebProxy可供您進一步自訂的實例; 兩者之間的差異在於實例在傳回至您的應用程式之前如何初始化。These methods each supply a WebProxy instance that you can further customize; the difference between them is how the instance is initialized before it is returned to your application. WebProxy函式會傳回WebProxy類別的實例, 並Address將屬性設定null為。The WebProxy constructor returns an instance of the WebProxy class with the Address property set to null. 當要求使用處于此WebProxy狀態的實例時, 不會使用任何 proxy 來傳送要求。When a request uses a WebProxy instance in this state, no proxy is used to send the request.

WebProxy BypassProxyOnLocal BypassList方法會傳回類別Address的實例, 並將、和屬性設定為 Internet Explorer 5.5 和更新版本所使用的值。 GetDefaultProxyThe GetDefaultProxy method returns an instance of the WebProxy class with the Address, BypassProxyOnLocal, and BypassList properties set to the values used by Internet Explorer 5.5 and later.

方法會傳回WebProxy類別的實例, 並根據 Internet Explorer 和設定檔案設定的組合設定它的屬性。 SelectThe Select method returns an instance of the WebProxy class with it properties set according to a combination of Internet Explorer and configuration file settings.

WebProxy類別支援自動偵測及執行 proxy 設定腳本。The WebProxy class supports automatic detection and execution of proxy configuration scripts. 這項功能也稱為「Web Proxy 自動探索 (WPAD)」。This feature is also known as Web Proxy Auto-Discovery (WPAD). 使用自動 proxy 設定時, 必須找出、下載、編譯及執行設定腳本 (通常名為 Wpad. dat)。When using automatic proxy configuration, a configuration script, typically named Wpad.dat, must be located, downloaded, compiled, and run. 如果這些作業成功, 腳本會傳回可用於要求的 proxy。If these operations are successful, the script returns the proxies that can be used for a request.

建構函式

WebProxy() WebProxy() WebProxy() WebProxy()

初始化 WebProxy 類別的空執行個體。Initializes an empty instance of the WebProxy class.

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

使用先前序列化的內容,初始化 WebProxy 類別的執行個體。Initializes an instance of the WebProxy class using previously serialized content.

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

使用指定的 URI,初始化 WebProxy 類別的新執行個體。Initializes a new instance of the WebProxy class with the specified URI.

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

使用指定 URI 和略過設定,初始化 WebProxy 類別的新執行個體。Initializes a new instance of the WebProxy class with the specified URI and bypass setting.

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

使用指定位址、略過設定和要略過的 URI 清單,初始化 WebProxy 類別的新執行個體。Initializes a new instance of the WebProxy class with the specified URI, 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)

使用指定 URI、略過設定、要略過的 URI 清單和認證,初始化 WebProxy 類別的新執行個體。Initializes a new instance of the WebProxy class with the specified URI, bypass setting, list of URIs to bypass, and credentials.

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

使用指定主機和連接埠編號,初始化 WebProxy 類別的新執行個體。Initializes a new instance of the WebProxy class with the specified host and port number.

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

從指定的 WebProxy 執行個體,初始化 Uri 類別的新執行個體。Initializes a new instance of the WebProxy class from the specified Uri instance.

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

使用 WebProxy 執行個體和略過設定,初始化 Uri 類別的新執行個體。Initializes a new instance of the WebProxy class with the Uri instance and bypass setting.

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

使用指定的 WebProxy 執行個體、略過設定和要略過的 URI 清單,初始化 Uri 類別的新執行個體。Initializes a new instance of the WebProxy class with the specified Uri instance, bypass setting, and list of URIs to bypass.

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

使用指定的 WebProxy 執行個體、略過設定、要略過的 URI 清單和認證,初始化 Uri 類別的新執行個體。Initializes a new instance of the WebProxy class with the specified Uri instance, bypass setting, list of URIs to bypass, and credentials.

屬性

Address Address Address Address

取得或設定 Proxy 伺服器的位址。Gets or sets the address of the proxy server.

BypassArrayList BypassArrayList BypassArrayList BypassArrayList

取得不使用 Proxy 伺服器的位址清單。Gets a list of addresses that do not use the proxy server.

BypassList BypassList BypassList BypassList

取得或設定不使用 Proxy 伺服器的位址陣列。Gets or sets an array of addresses that do not use the proxy server.

BypassProxyOnLocal BypassProxyOnLocal BypassProxyOnLocal BypassProxyOnLocal

取得或設定值,這個值會指出是否對本機位址略過 Proxy 伺服器。Gets or sets a value that indicates whether to bypass the proxy server for local addresses.

Credentials Credentials Credentials Credentials

取得或設定認證,提交到 Proxy 伺服器進行驗證。Gets or sets the credentials to submit to the proxy server for authentication.

UseDefaultCredentials UseDefaultCredentials UseDefaultCredentials UseDefaultCredentials

取得或設定 Boolean 值,控制是否隨著要求傳送 DefaultCredentialsGets or sets a Boolean value that controls whether the DefaultCredentials are sent with requests.

方法

CreateDefaultProxy() CreateDefaultProxy() CreateDefaultProxy() CreateDefaultProxy()
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetDefaultProxy() GetDefaultProxy() GetDefaultProxy() GetDefaultProxy()

讀取 Internet Explorer 非動態 Proxy 設定。Reads the Internet Explorer nondynamic proxy settings.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

將序列化目標物件所需的資料填入 SerializationInfoPopulates a SerializationInfo with the data that is needed to serialize the target object.

GetProxy(Uri) GetProxy(Uri) GetProxy(Uri) GetProxy(Uri)

傳回要求的代理 URI。Returns the proxied URI for a request.

GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
IsBypassed(Uri) IsBypassed(Uri) IsBypassed(Uri) IsBypassed(Uri)

指示是否要為指定主機使用 Proxy 伺服器。Indicates whether to use the proxy server for the specified host.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

明確介面實作

ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext)

建立系統用來序列化 WebProxy 物件的序列化資料和內容。Creates the serialization data and context that are used by the system to serialize a WebProxy object.

適用於