HttpResponseMessageProperty 類別

定義

提供對 HTTP 回應的存取,以便存取及回應透過 HTTP 通訊協定來提供給要求使用的其他資訊。

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

範例

這樣會示範如何建立 HttpResponseProperty 類別的執行個體及修改它的某些成員:

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

備註

這是一般用途的類別,可讓您直接存取 HTTP 回應資訊,這些資訊可用於封裝 HTTP 特定的資訊。 使用這個類別的一個範例就是支援根據代表性狀態傳輸 (REST) 架構所實作的服務。

這個類別可讓您支援以下案例:

  • 控制是否要傳輸實體。

  • 允許為每一個回應設定 HTTP 標頭 (索引鍵, 值) 組。

  • 讓用於每一個回應的狀態碼和狀態說明有所差異。

這個類別可由 HttpTransportBindingElement 和相關類別使用。

建構函式

HttpResponseMessageProperty()

初始化 HttpResponseMessageProperty 類別的新執行個體。

屬性

Headers

從 HTTP 回應取得 HTTP 標頭。

HttpResponseMessage

提供對 HTTP 回應的存取,以便存取及回應透過 HTTP 通訊協定來提供給要求使用的其他資訊。

Name

取得與 HttpResponseMessageProperty 類別相關聯之訊息屬性的名稱。

StatusCode

取得或設定目前附加此屬性之 HTTP 回應的狀態碼。

StatusDescription

取得或設定目前附加此屬性之 HTTP 回應的狀態碼說明。

SuppressEntityBody

取得或設定值,這個值指出是否要忽略訊息本文及傳送空的訊息。

SuppressPreamble

取得或設定是否隱藏訊息前置訊號。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

IMessageProperty.CreateCopy()

建立目前執行個體的新複本。

適用於