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)