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 标头 (key, value) 对。

  • 对每个响应都使用不同的状态代码和状态说明。

此类可由 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()

创建当前实例的新副本。

适用于