WebOperationContext Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
-
WebOperationContext
- 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) |
Initializes a new instance of the WebOperationContext class with the specified OperationContext instance. |
Properties
Current |
Gets the current Web operation context. |
IncomingRequest |
Gets the Web request context for the request being received. |
IncomingResponse |
Gets the Web response context for the request being received. |
OutgoingRequest |
Gets the Web request context for the request being sent. |
OutgoingResponse |
Gets the Web response context for the response being sent. |
Methods
Attach(OperationContext) |
Attaches the current WebOperationContext instance to the specified OperationContext instance. |
CreateAtom10Response(ServiceDocument) |
Creates a message formatted according to the Atom 1.0 specification with the specified content. |
CreateAtom10Response(SyndicationFeed) |
Creates a message formatted according to the Atom 1.0 specification with the specified content. |
CreateAtom10Response(SyndicationItem) |
Creates a message formatted according to the Atom 1.0 specification with the specified content. |
CreateJsonResponse<T>(T) |
Creates a JSON formatted message. |
CreateJsonResponse<T>(T, DataContractJsonSerializer) |
Creates a JSON formatted message. |
CreateStreamResponse(Action<Stream>, String) |
Creates a stream formatted message. |
CreateStreamResponse(Stream, String) |
Creates a stream formatted message. |
CreateStreamResponse(StreamBodyWriter, String) |
Creates a stream formatted message. |
CreateTextResponse(Action<TextWriter>, String) |
Creates a text formatted message. |
CreateTextResponse(Action<TextWriter>, String, Encoding) |
Creates a text formatted message. |
CreateTextResponse(String) |
Creates a text formatted response message. |
CreateTextResponse(String, String) |
Creates a text formatted message. |
CreateTextResponse(String, String, Encoding) |
Creates a text formatted message. |
CreateXmlResponse(XDocument) |
Creates an XML formatted message. |
CreateXmlResponse(XElement) |
Creates an XML formatted message. |
CreateXmlResponse<T>(T) |
Creates an XML formatted message. |
CreateXmlResponse<T>(T, XmlObjectSerializer) |
Creates an XML formatted message. |
CreateXmlResponse<T>(T, XmlSerializer) |
Creates an XML formatted message. |
Detach(OperationContext) |
Detaches the current WebOperationContext instance from the specified OperationContext instance. |
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
GetUriTemplate(String) |
Gets the URI template associated with the specified operation. |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |