IContextManager Interface
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.
Defines an interface that allows you to get and set the context on the channel.
public interface class IContextManager
public interface IContextManager
type IContextManager = interface
Public Interface IContextManager
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 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);
}
}
Enabled |
Gets or sets a value that indicates whether the context management is enabled. |
Get |
Gets the context. |
Set |
Sets the context. |
Product | Versions |
---|---|
.NET Framework | 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: