IContextManager Interface

Defines an interface that allows you to get and set the context on the channel.

Namespace:  System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public interface IContextManager

The IContextManager type exposes the following members.

  NameDescription
Public propertyEnabledGets or sets a value that indicates whether the context management is enabled.
Top

  NameDescription
Public methodGetContextGets the context.
Public methodSetContextSets the context.
Top

For channels that use WSHttpContextBinding with the NotAllowed value set, the context cannot be retrieved on the client using IContextManager because a new channel that establishes a session is created each time GetProperty<T> is called to enforce NotAllowed semantics on a channel. This means that even though the context is properly propagated back to the client in this case, it cannot be retrieved using IContextManager. You can still retrieve it using ContextMessageProperty as shown in the following code.

using (new OperationContextScope((IContextChannel)channel))
{
    channel.MyChannel("Test");
    ContextMessageProperty context;
    if (ContextMessageProperty.TryGet(OperationContext.Current.IncomingMessageProperties, out context))
    {
        Console.WriteLine(context.Count);
    }
}

.NET Framework

Supported in: 4, 3.5

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft