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.WorkflowServices (in System.WorkflowServices.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.

Binding

IContextManager.Enabled Value

Context HTTP Cookie Scope

Other HTTP Cookies Scope

BasicHttpBinding

n/a

ChannelFactory

ChannelFactory

BasicHttpContextBinding

true

Channel

Channel

BasicHttpContextBinding

false

For each message (explicitly managed by application)

Channel

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
Show: