WebOperationContext WebOperationContext WebOperationContext WebOperationContext Class

Definition

A helper class that provides easy access to contextual properties of Web requests and responses.

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)
Inheritance
WebOperationContextWebOperationContextWebOperationContextWebOperationContext
Implements

Examples

The following code shows how to retrieve the UriTemplateMatch instance associated with the Web operation context of the current call. The code also shows how to set the HTTP status for the outgoing response.

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)

Constructors

WebOperationContext(OperationContext) WebOperationContext(OperationContext) WebOperationContext(OperationContext) WebOperationContext(OperationContext)

Initializes a new instance of the WebOperationContext class with the specified OperationContext instance.

Properties

Current Current Current Current

Gets the current Web operation context.

IncomingRequest IncomingRequest IncomingRequest IncomingRequest

Gets the Web request context for the request being received.

IncomingResponse IncomingResponse IncomingResponse IncomingResponse

Gets the Web response context for the request being received.

OutgoingRequest OutgoingRequest OutgoingRequest OutgoingRequest

Gets the Web request context for the request being sent.

OutgoingResponse OutgoingResponse OutgoingResponse OutgoingResponse

Gets the Web response context for the response being sent.

Methods

Attach(OperationContext) Attach(OperationContext) Attach(OperationContext) Attach(OperationContext)

Attaches the current WebOperationContext instance to the specified OperationContext instance.

CreateAtom10Response(ServiceDocument) CreateAtom10Response(ServiceDocument) CreateAtom10Response(ServiceDocument) CreateAtom10Response(ServiceDocument)

Creates a message formatted according to the Atom 1.0 specification with the specified content.

CreateAtom10Response(SyndicationFeed) CreateAtom10Response(SyndicationFeed) CreateAtom10Response(SyndicationFeed) CreateAtom10Response(SyndicationFeed)

Creates a message formatted according to the Atom 1.0 specification with the specified content.

CreateAtom10Response(SyndicationItem) CreateAtom10Response(SyndicationItem) CreateAtom10Response(SyndicationItem) CreateAtom10Response(SyndicationItem)

Creates a message formatted according to the Atom 1.0 specification with the specified content.

CreateJsonResponse<T>(T) CreateJsonResponse<T>(T) CreateJsonResponse<T>(T) CreateJsonResponse<T>(T)

Creates a JSON formatted message.

CreateJsonResponse<T>(T, DataContractJsonSerializer) CreateJsonResponse<T>(T, DataContractJsonSerializer) CreateJsonResponse<T>(T, DataContractJsonSerializer) CreateJsonResponse<T>(T, DataContractJsonSerializer)

Creates a JSON formatted message.

CreateStreamResponse(Action<Stream>, String) CreateStreamResponse(Action<Stream>, String) CreateStreamResponse(Action<Stream>, String) CreateStreamResponse(Action<Stream>, String)

Creates a stream formatted message.

CreateStreamResponse(Stream, String) CreateStreamResponse(Stream, String) CreateStreamResponse(Stream, String) CreateStreamResponse(Stream, String)

Creates a stream formatted message.

CreateStreamResponse(StreamBodyWriter, String) CreateStreamResponse(StreamBodyWriter, String) CreateStreamResponse(StreamBodyWriter, String) CreateStreamResponse(StreamBodyWriter, String)

Creates a stream formatted message.

CreateTextResponse(Action<TextWriter>, String) CreateTextResponse(Action<TextWriter>, String) CreateTextResponse(Action<TextWriter>, String) CreateTextResponse(Action<TextWriter>, String)

Creates a text formatted message

CreateTextResponse(Action<TextWriter>, String, Encoding) CreateTextResponse(Action<TextWriter>, String, Encoding) CreateTextResponse(Action<TextWriter>, String, Encoding) CreateTextResponse(Action<TextWriter>, String, Encoding)

Creates a text formatted message

CreateTextResponse(String) CreateTextResponse(String) CreateTextResponse(String) CreateTextResponse(String)

Creates a text formatted response message.

CreateTextResponse(String, String) CreateTextResponse(String, String) CreateTextResponse(String, String) CreateTextResponse(String, String)

Creates a text formatted message.

CreateTextResponse(String, String, Encoding) CreateTextResponse(String, String, Encoding) CreateTextResponse(String, String, Encoding) CreateTextResponse(String, String, Encoding)

Creates a text formatted message.

CreateXmlResponse(XDocument) CreateXmlResponse(XDocument) CreateXmlResponse(XDocument) CreateXmlResponse(XDocument)

Creates an XML formatted message.

CreateXmlResponse(XElement) CreateXmlResponse(XElement) CreateXmlResponse(XElement) CreateXmlResponse(XElement)

Creates an XML formatted message.

CreateXmlResponse<T>(T) CreateXmlResponse<T>(T) CreateXmlResponse<T>(T) CreateXmlResponse<T>(T)

Creates an XML formatted message.

CreateXmlResponse<T>(T, XmlObjectSerializer) CreateXmlResponse<T>(T, XmlObjectSerializer) CreateXmlResponse<T>(T, XmlObjectSerializer) CreateXmlResponse<T>(T, XmlObjectSerializer)

Creates an XML formatted message.

CreateXmlResponse<T>(T, XmlSerializer) CreateXmlResponse<T>(T, XmlSerializer) CreateXmlResponse<T>(T, XmlSerializer) CreateXmlResponse<T>(T, XmlSerializer)

Creates an XML formatted message.

Detach(OperationContext) Detach(OperationContext) Detach(OperationContext) Detach(OperationContext)

Detaches the current WebOperationContext instance from the specified OperationContext instance.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
GetUriTemplate(String) GetUriTemplate(String) GetUriTemplate(String) GetUriTemplate(String)

Gets the URI template associated with the specified operation.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to