WebOperationContext Class
.NET Framework 4.5
A helper class that provides easy access to contextual properties of Web requests and responses.
Namespace:
System.ServiceModel.Web
Assembly: System.ServiceModel.Web (in System.ServiceModel.Web.dll)
The WebOperationContext type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | WebOperationContext | Initializes a new instance of the WebOperationContext class with the specified OperationContext instance. |
| Name | Description | |
|---|---|---|
![]() ![]() | 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. |
| Name | Description | |
|---|---|---|
![]() | Attach | 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(String) | Creates a text formatted response message. |
![]() | CreateTextResponse(Action<TextWriter>, String) | Creates a text formatted message |
![]() | CreateTextResponse(String, String) | Creates a text formatted message. |
![]() | CreateTextResponse(Action<TextWriter>, String, Encoding) | 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 | 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.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | GetUriTemplate | 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.) |
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);
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
