HttpResponseMessageProperty 類別

定義

提供對 HTTP 回應的存取,以便存取及回應透過 HTTP 通訊協定來提供給要求使用的其他資訊。Provides access to the HTTP response in order to access and respond to the additional information made available for requests over the HTTP protocol.

public ref class HttpResponseMessageProperty sealed : System::ServiceModel::Channels::IMessageProperty
public sealed class HttpResponseMessageProperty : System.ServiceModel.Channels.IMessageProperty
type HttpResponseMessageProperty = class
    interface IMessageProperty
Public NotInheritable Class HttpResponseMessageProperty
Implements IMessageProperty
繼承
HttpResponseMessageProperty
實作

範例

這樣會示範如何建立 HttpResponseProperty 類別的執行個體及修改它的某些成員:This shows how to use create an instance of the HttpResponseProperty class and modify some of its members:

HttpResponseMessageProperty responseProperty =
    new HttpResponseMessageProperty();
responseProperty.StatusCode = HttpStatusCode.OK;
responseProperty.Headers.Add(
                 HttpResponseHeader.ContentType,
                 "text/html; charset=UTF-8");

備註

這是一般用途的類別,可讓您直接存取 HTTP 回應資訊,這些資訊可用於封裝 HTTP 特定的資訊。This is a general-purpose class that gives you direct access to the HTTP response information, which could be used for encapsulation of HTTP-specific information. 使用這個類別的一個範例就是支援根據代表性狀態傳輸 (REST) 架構所實作的服務。One use of this class is to support services implemented in accordance with the Representational State Transfer (REST) architecture.

這個類別可讓您支援以下案例:This class enables you to support the following scenarios:

  • 控制是否要傳輸實體。Controls whether an entity body is transmitted.

  • 允許為每一個回應設定 HTTP 標頭 (索引鍵, 值) 組。Allows HTTP header (key, value) pairs to be set for each response.

  • 讓用於每一個回應的狀態碼和狀態說明有所差異。Varies the status code and status description used for each response.

這個類別可由 HttpTransportBindingElement 和相關類別使用。This class can be used by HttpTransportBindingElement and related classes.

建構函式

HttpResponseMessageProperty()

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

屬性

Headers

從 HTTP 回應取得 HTTP 標頭。Gets the HTTP headers from the HTTP response.

Name

取得與 HttpResponseMessageProperty 類別相關聯之訊息屬性的名稱。Gets the name of the message property associated with the HttpResponseMessageProperty class.

StatusCode

取得或設定目前附加此屬性之 HTTP 回應的狀態碼。Gets or sets the status code of the current HTTP response to which this property is attached.

StatusDescription

取得或設定目前附加此屬性之 HTTP 回應的狀態碼說明。Gets or sets the description of the status code of the current HTTP response to which this property is attached.

SuppressEntityBody

取得或設定值,這個值指出是否要忽略訊息本文及傳送空的訊息。Gets or sets a value that indicates whether the body of the message is ignored and an empty message is sent.

SuppressPreamble

取得或設定是否隱藏訊息前置訊號。Gets or sets whether the message preamble is suppressed.

方法

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

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

(繼承來源 Object)
GetType()

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

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

明確介面實作

IMessageProperty.CreateCopy()

建立目前執行個體的新複本。Creates a new copy of the current instance.

適用於