Export (0) Print
Expand All

OptionalReliableSession.Enabled Property

Gets or sets a value that indicates whether the reliable session is enabled.

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

public bool Enabled { get; set; }

Property Value

Type: System.Boolean
true if the reliable session is enabled; otherwise, false. The default value depends on the binding being used.

The ability to enable a reliable session is provided with three of the system-provided bindings. A reliable session is:

The following example shows how to create a new reliable session, access and change the default values of that session.

private void Run()
    WSHttpBinding b = new WSHttpBinding();
    b.Name = "HttpOrderedReliableSessionBinding";

    // Get a reference to the OptionalreliableSession object of the  
    // binding and set its properties to new values.
    OptionalReliableSession myReliableSession = b.ReliableSession;
    myReliableSession.Enabled = true; // The default is false.
    myReliableSession.Ordered = false; // The default is true. 
    myReliableSession.InactivityTimeout = 
        new TimeSpan(0, 15, 0); // The default is 10 minutes. 
    // Create a URI for the service's base address.
    Uri baseAddress = new Uri("http://localhost:8008/Calculator");

    // Create a service host.
    ServiceHost sh = new ServiceHost(typeof(Calculator), baseAddress);

    // Optional: Print out the binding information. 
    // Create a URI for an endpoint, then add a service endpoint using the 
    // binding with the latered OptionalReliableSession settings.
    sh.AddServiceEndpoint(typeof(ICalculator), b, "ReliableCalculator");



private void PrintBindingInfo(WSHttpBinding b)
    Console.WriteLine("Enabled: {0}", b.ReliableSession.Enabled);
    Console.WriteLine("Ordered: {0}", b.ReliableSession.Ordered);
    Console.WriteLine("Inactivity in Minutes: {0}",

.NET Framework

Supported in: 4.5.3, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft