WebOperationContext.OutgoingResponse 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取正在发送的响应的 Web 响应上下文。
public:
property System::ServiceModel::Web::OutgoingWebResponseContext ^ OutgoingResponse { System::ServiceModel::Web::OutgoingWebResponseContext ^ get(); };
public System.ServiceModel.Web.OutgoingWebResponseContext OutgoingResponse { get; }
member this.OutgoingResponse : System.ServiceModel.Web.OutgoingWebResponseContext
Public ReadOnly Property OutgoingResponse As OutgoingWebResponseContext
属性值
一个 OutgoingWebResponseContext 实例。
示例
以下代码演示如何设置传出响应的状态。
counter++;
UriTemplateMatch match = WebOperationContext.Current.IncomingRequest.UriTemplateMatch;
UriTemplate template = new UriTemplate("{id}");
customer.Uri = template.BindByPosition(match.BaseUri, counter.ToString());
customers[counter.ToString()] = customer;
WebOperationContext.Current.OutgoingResponse.SetStatusAsCreated(customer.Uri);
counter = counter + 1
Dim match As UriTemplateMatch = WebOperationContext.Current.IncomingRequest.UriTemplateMatch
Dim template As New UriTemplate("{id}")
customer.Uri = template.BindByPosition(match.BaseUri, counter.ToString())
customers(counter.ToString()) = customer
WebOperationContext.Current.OutgoingResponse.SetStatusAsCreated(customer.Uri)