WebResponse WebResponse WebResponse WebResponse Class

定義

提供來自統一資源識別元 (URI) 的回應。Provides a response from a Uniform Resource Identifier (URI). 這是 abstract 類別。This is an abstract class.

public ref class WebResponse abstract : MarshalByRefObject, IDisposable, System::Runtime::Serialization::ISerializable
[System.Serializable]
public abstract class WebResponse : MarshalByRefObject, IDisposable, System.Runtime.Serialization.ISerializable
type WebResponse = class
    inherit MarshalByRefObject
    interface ISerializable
    interface IDisposable
Public MustInherit Class WebResponse
Inherits MarshalByRefObject
Implements IDisposable, ISerializable
繼承
衍生
屬性
實作

範例

下列範例會建立WebResponse執行個體WebRequestThe following example creates a WebResponse instance from a WebRequest.

// Initialize the WebRequest.
WebRequest^ myRequest = WebRequest::Create( "http://www.contoso.com" );

// Return the response. 
WebResponse^ myResponse = myRequest->GetResponse();

// Code to use the WebResponse goes here.

// Close the response to free resources.
myResponse->Close();
// Initialize the WebRequest.
WebRequest myRequest = WebRequest.Create("http://www.contoso.com");

// Return the response. 
WebResponse myResponse = myRequest.GetResponse();

// Code to use the WebResponse goes here.

// Close the response to free resources.
myResponse.Close();

' Initialize the WebRequest.
Dim myRequest As WebRequest = WebRequest.Create("http://www.contoso.com")

' Return the response. 
Dim myResponse As WebResponse = myRequest.GetResponse()

' Code to use the WebResponse goes here.
' Close the response to free resources.
myResponse.Close()

備註

WebResponse類別是abstract基底的類別,從其中衍生通訊協定特有的回應類別。The WebResponse class is the abstract base class from which protocol-specific response classes are derived. 應用程式可以參與要求和回應交易中使用的執行個體以通訊協定無關的方式WebResponse類別時通訊協定特定類別衍生自WebResponse執行要求的詳細資料。Applications can participate in request and response transactions in a protocol-agnostic manner using instances of the WebResponse class while protocol-specific classes derived from WebResponse carry out the details of the request.

用戶端應用程式不會建立WebResponse物件直接; 它們會藉由呼叫GetResponse方法WebRequest執行個體。Client applications do not create WebResponse objects directly; they are created by calling the GetResponse method on a WebRequest instance.

給繼承者的注意事項

當您繼承自WebResponse,您必須覆寫下列成員: ContentLengthContentTypeGetResponseStream()ResponseUri,和HeadersWhen you inherit from WebResponse, you must override the following members: ContentLength, ContentType, GetResponseStream(), ResponseUri, and Headers.

建構函式

WebResponse() WebResponse() WebResponse() WebResponse()

初始化 WebResponse 類別的新執行個體。Initializes a new instance of the WebResponse class.

WebResponse(SerializationInfo, StreamingContext) WebResponse(SerializationInfo, StreamingContext) WebResponse(SerializationInfo, StreamingContext) WebResponse(SerializationInfo, StreamingContext)

初始化 WebResponse 類別的新執行個體,這個執行個體是來自 SerializationInfoStreamingContext 類別的指定執行個體。Initializes a new instance of the WebResponse class from the specified instances of the SerializationInfo and StreamingContext classes.

屬性

ContentLength ContentLength ContentLength ContentLength

在子代類別中覆寫時,取得或設定正在接收資料的內容長度。When overridden in a descendant class, gets or sets the content length of data being received.

ContentType ContentType ContentType ContentType

在衍生類別中覆寫時,取得或設定正在接收資料的內容類型。When overridden in a derived class, gets or sets the content type of the data being received.

Headers Headers Headers Headers

在衍生類別中覆寫時,取得與這個要求相關聯的標頭名稱值配對集合。When overridden in a derived class, gets a collection of header name-value pairs associated with this request.

IsFromCache IsFromCache IsFromCache IsFromCache

取得 Boolean 值,指出這個回應是否從快取中取得。Gets a Boolean value that indicates whether this response was obtained from the cache.

IsMutuallyAuthenticated IsMutuallyAuthenticated IsMutuallyAuthenticated IsMutuallyAuthenticated

取得 Boolean 值,指出是否發生過相互驗證。Gets a Boolean value that indicates whether mutual authentication occurred.

ResponseUri ResponseUri ResponseUri ResponseUri

在衍生類別中覆寫時,取得對要求實際回應的網際網路資源 URI。When overridden in a derived class, gets the URI of the Internet resource that actually responded to the request.

SupportsHeaders SupportsHeaders SupportsHeaders SupportsHeaders

取得指出是否支援標頭的值。Gets a value that indicates if headers are supported.

方法

Close() Close() Close() Close()

當由子代類別覆寫時,關閉回應資料流。When overridden by a descendant class, closes the response stream.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

釋放由 WebResponse 物件使用的 Unmanaged 資源。Releases the unmanaged resources used by the WebResponse object.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

釋放 WebResponse 物件所使用的 Unmanaged 資源,並選擇性處置 Managed 資源。Releases the unmanaged resources used by the WebResponse object, and optionally disposes of the managed resources.

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

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

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
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.

GetResponseStream() GetResponseStream() GetResponseStream() GetResponseStream()

在子代類別中覆寫時,傳回來自網際網路資源的資料流。When overridden in a descendant class, returns the data stream from the Internet resource.

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

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

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

取得存留期服務物件,以控制這個執行個體的存留期原則。Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

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

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ToString() ToString() ToString() ToString()

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

(Inherited from Object)

明確介面實作

IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose()

在衍生類別中覆寫時,釋放 WebResponse 使用的所有資源。When overridden in a derived class, releases all resources used by the WebResponse.

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

以序列化 SerializationInfo 所需的資料填入 (Populate) WebResponse 執行個體。Populates a SerializationInfo instance with the data that is needed to serialize WebResponse.

適用於