title: How to enable Session with SSL wsHttpBinding in WCF
body: <p>I have a WCF Service with wsHttpBindings and SSL enabled, but I'd like to enable WCF sessions.  </p>
  
  <p>After changing SessionMode to required</p>
  
  <pre><code>SessionMode:=SessionMode.Required
  </code></pre>
  
  <p> I'm getting error described below. </p>
  
  <blockquote>
    <p>Contract requires Session, but Binding 'WSHttpBinding' doesn't support
    it or isn't configured properly to support it.</p>
  </blockquote>
  
  <p>Here's my sample application.</p>
  
  <p><strong>App.config</strong></p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="utf-8" ?&gt;
      &lt;configuration&gt;
  
        &lt;system.web&gt;
          &lt;compilation debug="true" /&gt;
        &lt;/system.web&gt;
        &lt;!-- When deploying the service library project, the content of the config file must be added to the host's 
        app.config file. System.Configuration does not support config files for libraries. --&gt;
        &lt;system.serviceModel&gt;
  
          &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" /&gt;
          &lt;client /&gt;
          &lt;bindings&gt;
            &lt;wsHttpBinding&gt;
              &lt;binding name="NewBinding0" useDefaultWebProxy="false" allowCookies="true"&gt;
                &lt;readerQuotas maxStringContentLength="10240" /&gt;
                &lt;!--reliableSession enabled="true" /--&gt;
                &lt;security mode="Transport"&gt;
                  &lt;transport clientCredentialType="None" proxyCredentialType="None" &gt;
                    &lt;extendedProtectionPolicy policyEnforcement="Never" /&gt;
                  &lt;/transport &gt;
                &lt;/security&gt;
              &lt;/binding&gt;
            &lt;/wsHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;services&gt;
            &lt;service name="WcfServiceLib.TestService"&gt;
              &lt;endpoint address="" binding="wsHttpBinding" bindingConfiguration="NewBinding0"
                contract="WcfServiceLib.ITestService"&gt;
                &lt;identity&gt;
                  &lt;servicePrincipalName value="Local Network" /&gt;
                &lt;/identity&gt;
              &lt;/endpoint&gt;
              &lt;endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /&gt;
              &lt;host&gt;
                &lt;baseAddresses&gt;
                  &lt;add baseAddress="https://test/TestService.svc" /&gt;
                &lt;/baseAddresses&gt;
              &lt;/host&gt;
            &lt;/service&gt;
          &lt;/services&gt;
  
          &lt;behaviors&gt;
            &lt;serviceBehaviors&gt;
              &lt;behavior&gt;
                &lt;!-- To avoid disclosing metadata information, 
                set the value below to false and remove the metadata endpoint above before deployment --&gt;
                &lt;serviceMetadata httpsGetEnabled="True"/&gt;
                &lt;!-- To receive exception details in faults for debugging purposes, 
                set the value below to true.  Set to false before deployment 
                to avoid disclosing exception information --&gt;
                &lt;serviceDebug includeExceptionDetailInFaults="False" /&gt;
              &lt;/behavior&gt;
            &lt;/serviceBehaviors&gt;
          &lt;/behaviors&gt;
        &lt;/system.serviceModel&gt;
  
      &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>ITestService.vb</strong></p>
  
  <pre><code>  &lt;ServiceContract(SessionMode:=SessionMode.Required)&gt;
      Public Interface ITestService
  
          &lt;OperationContract(IsInitiating:=True, IsTerminating:=False)&gt; _
          Function GetData(ByVal value As Integer) As String
  
      End Interface
  </code></pre>
  
  <p><strong>TestService.vb</strong></p>
  
  <pre><code>    &lt;ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession, _ 
      ReleaseServiceInstanceOnTransactionComplete:=False, _ 
      ConcurrencyMode:=ConcurrencyMode.Single)&gt;
          Public Class TestService
              Implements ITestService
  
              Private _user As User
  
              &lt;OperationBehavior(TransactionScopeRequired:=True)&gt;
              Public Function GetData(ByVal value As Integer) As String _
   Implements ITestService.GetData
  
                  If _user Is Nothing Then
  
                      _user = New User()
                      _user.userName = "User_" &amp; value
                      _user.userPassword = "Pass_" &amp; value
  
                      Return String.Format("You've entered: {0} , Username = {1} , Password = {2} ", _
                                           value, _user.userName, _user.userPassword)
                  Else
                      Return String.Format("Username = {1} , Password = {2} ", _
                                      _user.userName, _user.userPassword)
                  End If
  
              End Function
  
          End Class
  </code></pre>
  
  <p>I tried all possible solutions, I could find, but nothing helped. </p>
  
  <p>Some advice to enable <em>reliable sessions</em>, but it doesn't work with <strong>ssl</strong> (if only you have your custom binding), others advice to use <strong>http</strong> instead of <strong>https</strong>, but I'd like to enable Sessions with my current configurations, if it's possible. </p>
  
  <p>Is there any approach to achieve this? </p>
  
  <p>Any kind of help is much appreciated. </p>