共用方式為


HttpResponseMessage 類別

定義

表示 HTTP 回應訊息,包括標頭、狀態碼和資料。

public ref class HttpResponseMessage sealed : IClosable, IStringable
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Web.Http.IHttpResponseMessageFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class HttpResponseMessage final : IClosable, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Web.Http.IHttpResponseMessageFactory, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class HttpResponseMessage final : IClosable, IStringable
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Web.Http.IHttpResponseMessageFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class HttpResponseMessage : System.IDisposable, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Web.Http.IHttpResponseMessageFactory), 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class HttpResponseMessage : System.IDisposable, IStringable
function HttpResponseMessage(statusCode)
Public NotInheritable Class HttpResponseMessage
Implements IDisposable, IStringable
繼承
Object Platform::Object IInspectable HttpResponseMessage
屬性
實作

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

備註

取得 HttpResponseMessage 的常見方式是從HttpClient物件上其中一個DeleteAsyncGetAsyncPostAsyncPutAsyncSendRequestAsync方法的傳回值。

建構函式

HttpResponseMessage()

初始化 HttpResponseMessage 類別的新實例。

HttpResponseMessage(HttpStatusCode)

使用特定的HttpStatusCode,初始化HttpResponseMessage類別的新實例。

屬性

Content

取得或設定 HttpResponseMessage 物件上 HTTP 回應訊息的內容。

Headers

取得與伺服器所傳送 之 HttpResponseMessage 相關聯的 HTTP 回應標頭集合。

IsSuccessStatusCode

取得值,這個值表示 HTTP 回應是否成功。

ReasonPhrase

取得或設定通常由伺服器連同狀態碼傳送的原因片語。

RequestMessage

取得或設定導致這個回應訊息的要求訊息。

Source

取得 在 HttpResponseMessage中收到的資料來源。

StatusCode

取得或設定 HTTP 回應的狀態碼。

Version

取得或設定 HttpResponseMessage 物件上使用的 HTTP 通訊協定版本。

方法

Close()

關閉 HttpResponseMessage 實例,並釋放已配置的資源。

Dispose()

執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。

EnsureSuccessStatusCode()

如果 HTTP 回應物件的 HttpResponseMessage.IsSuccessStatusCode 屬性為 false ,則會擲回例外狀況;如果是 true ,則不會擲回例外狀況。

ToString()

會傳回表示目前 HttpResponseMessage 物件的字串。

適用於

另請參閱