System.ServiceModel 4.0.0.0 System.Enum

Use the enumeration with the property to require, allow, or prohibit bindings to use sessions between endpoints that connect to or support the service contract. A session is a way of correlating a set of messages exchanged between two or more endpoints. For more information about sessions, see Using Sessions.

If your service supports sessions, you can then use the property to specify the relationship between instances of your service contract implementation and the channel session.

For example, if the property is set to and the property is set to , a client can use a binding that supports reliable sessions to make repeated calls to the same service object.

Because a session is a channel-level concept that the application model uses, there is an interaction between the enumeration in a contract and the property, which controls the association between channels and specific service objects.

The following table shows the result of an incoming channel either supporting reliable sessions or not supporting reliable sessions given a service's combination of the values of the property and the property.

InstanceContextMode Value

PerCall

Behavior with sessionful channel: A session and for each call.

Behavior with sessionless channel: An exception is thrown.

Behavior with sessionful channel: A session and for each call.

Behavior with sessionless channel: An for each call.

Behavior with sessionful channel: An exception is thrown.

Behavior with sessionless channel: An for each call.

PerSession

Behavior with sessionful channel: A session and for each channel.

Behavior with sessionless channel: An exception is thrown.

Behavior with sessionful channel: A session and for each channel.

Behavior with sessionless channel: An for each call.

Behavior with sessionful channel: An exception is thrown.

Behavior with sessionless channel: An for each call.

Single

Behavior with sessionful channel: One session and one for all calls.

Behavior with sessionless channel: An exception is thrown.

Behavior with sessionful channel: A session and for each created singleton or for the user-specified singleton.

Behavior with sessionless channel: An for each created singleton or for the user-specified singleton.

Behavior with sessionful channel: An exception is thrown.

Behavior with sessionless channel: An for each created singleton or for the user-specified singleton.

Specifies the values available to indicate the support for reliable sessions that a contract requires or supports.

- Field
  4.0.0.0
  System.ServiceModel.SessionMode

  Specifies that the contract supports sessions if the incoming binding supports them.

- Field
  4.0.0.0
  System.ServiceModel.SessionMode

  Specifies that the contract never supports bindings that initiate sessions.

- Field
  4.0.0.0
  System.ServiceModel.SessionMode

  Specifies that the contract requires a sessionful binding. An exception is thrown if the binding is not configured to support session.