WebOperationContext 類別

定義

提供簡易存取 Web 要求與回應之內容屬性的 Helper 類別。

public ref class WebOperationContext : System::ServiceModel::IExtension<System::ServiceModel::OperationContext ^>
public class WebOperationContext : System.ServiceModel.IExtension<System.ServiceModel.OperationContext>
type WebOperationContext = class
    interface IExtension<OperationContext>
Public Class WebOperationContext
Implements IExtension(Of OperationContext)
繼承
WebOperationContext
實作

範例

下列程式碼會示範如何擷取與目前呼叫之 Web 作業內容相關聯的 UriTemplateMatch 執行個體。 此程式碼也會示範如何設定傳出回應的 HTTP 狀態。

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)

建構函式

WebOperationContext(OperationContext)

使用指定的 WebOperationContext 執行個體,初始化 OperationContext 類別的新執行個體。

屬性

Current

取得目前 Web 作業內容。

IncomingRequest

取得接收到之要求的 Web 要求內容。

IncomingResponse

取得接收到之要求的 Web 回應內容。

OutgoingRequest

取得傳送之要求的 Web 要求內容。

OutgoingResponse

取得傳送之回應的 Web 回應內容。

方法

Attach(OperationContext)

附加目前 WebOperationContext 執行個體至指定的 OperationContext 執行個體。

CreateAtom10Response(ServiceDocument)

使用指定的內容,建立根據 Atom 1.0 規格的格式化訊息。

CreateAtom10Response(SyndicationFeed)

使用指定的內容,建立根據 Atom 1.0 規格的格式化訊息。

CreateAtom10Response(SyndicationItem)

使用指定的內容,建立根據 Atom 1.0 規格的格式化訊息。

CreateJsonResponse<T>(T)

建立 JSON 格式化的訊息。

CreateJsonResponse<T>(T, DataContractJsonSerializer)

建立 JSON 格式化的訊息。

CreateStreamResponse(Action<Stream>, String)

建立資料流格式化的訊息。

CreateStreamResponse(Stream, String)

建立資料流格式化的訊息。

CreateStreamResponse(StreamBodyWriter, String)

建立資料流格式化的訊息。

CreateTextResponse(Action<TextWriter>, String)

建立文字格式化的訊息。

CreateTextResponse(Action<TextWriter>, String, Encoding)

建立文字格式化的訊息。

CreateTextResponse(String)

建立文字格式化的回應訊息。

CreateTextResponse(String, String)

建立文字格式化的訊息。

CreateTextResponse(String, String, Encoding)

建立文字格式化的訊息。

CreateXmlResponse(XDocument)

建立 XML 格式化的訊息。

CreateXmlResponse(XElement)

建立 XML 格式化的訊息。

CreateXmlResponse<T>(T)

建立 XML 格式化的訊息。

CreateXmlResponse<T>(T, XmlObjectSerializer)

建立 XML 格式化的訊息。

CreateXmlResponse<T>(T, XmlSerializer)

建立 XML 格式化的訊息。

Detach(OperationContext)

從指定的 WebOperationContext 執行個體中卸離目前的 OperationContext 執行個體。

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetUriTemplate(String)

取得與指定作業相關聯的 URI 範本。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

適用於