Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
WebOperationContext Class

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)
Visual Basic (Declaration)
Public Class WebOperationContext _
    Implements IExtension(Of OperationContext)
Visual Basic (Usage)
Dim instance As WebOperationContext
C#
public class WebOperationContext : IExtension<OperationContext>
Visual C++
public ref class WebOperationContext : IExtension<OperationContext^>
JScript
public class WebOperationContext implements IExtension<OperationContext>

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.

Visual Basic
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)

C#
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);


System..::.Object
  System.ServiceModel.Web..::.WebOperationContext
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker