Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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

NameDescription
System_CAPS_pubpropertyEnabled

Gets or sets a value that indicates whether the context management is enabled.

NameDescription
System_CAPS_pubmethodGetContext()

Gets the context.

System_CAPS_pubmethodSetContext(IDictionary(Of String, String))

Sets the context.

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(Of 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
Available since 3.5
Return to top
Show:
© 2017 Microsoft