This documentation is archived and is not being maintained.

IContextManager.Enabled Property

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

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

bool Enabled { get; set; }

Property Value

Type: System.Boolean
true if the context is enabled; otherwise, false.

When context management is enabled the context channel caches the context in its lifetime. Context can be retrieved from the channel through the IContextManager channel property by calling GetContext method on it. The channel can also be pre-initialized with context before being opened by calling the SetContext method on the channel property. Once the channel is initialized with context it cannot be reset.

The following are invariants in this mode:

  • Any call to SetContext after the channel is open throws an InvalidOperationException.

  • Any attempt to send context through the ContextMessageProperty in an outgoing message throws InvalidOperationException.

  • If a message is received from the server with context, when the channel is already initialized with a context a ProtocolException is thrown. Note that you can receive initial context from a server if the channel is opened without explicitly setting the context.

  • The ContextMessageProperty on an incoming message is always null.

When context management is not enabled, the context channel does not manage context. It is the application's responsibility to retrieve, manage and apply context through the ContextMessageProperty. Any attempt to call GetContext or SetContext using through the IContextManager channel property results in InvalidOperationException.

All HTTP cookies, except for context HTTP cookies, are handled at the channel level. Context HTTP cookies are managed at the application level. This can have unexpected consequences when channels are shared to talk to different instances targeted by ContextMessageProperty. The following table shows how HTTP cookies are affected when Enabled is set to either true or false.


IContextManager.Enabled Value

Context HTTP Cookie Scope

Other HTTP Cookies Scope











For each message (explicitly managed by application)


.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.