title: Why WCF InstanceContextMode.PerSession is not working over https?
body: <p>I have problems with  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession )]</p>
  
  <p>I have simple wcf service, which is hosted in IIS 7.</p>
  
  <p>Service code:</p>
  
  <pre><code>[ServiceContract(SessionMode = SessionMode.Allowed)]
  public interface IService1
  {
      [OperationContract]
      int SetMyValue(int val);
  
      [OperationContract]
      int GetMyValue();
  }
  
  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession )]
  public class Service1 : IService1
  {
      int MyValue = 0;
  
      public int SetMyValue(int val)
      {
          MyValue = val;
          return MyValue;
      }
  
      public int GetMyValue()
      {
          return MyValue;
      }
  
  }
  </code></pre>
  
  <p>Everything works if service site uses http.
  For example [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession  )] result for client is:</p>
  
  <p>Service1Client client = new Service1Client();<br>
  client.GetMyValue();     //==> returns 0<br>
  client.SetMyValue(1);   //==> returns 1<br>
  client.GetMyValue();    //==> returns 1<br>
  client.SetMyValue(6);    //==> returns 6<br>
  client.GetMyValue();    //==> returns 6<br></p>
  
  <p>[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall  )] result for client is:</p>
  
  <p>Service1Client client = new Service1Client();<br>
            client.GetMyValue();     //==> returns 0<br>
              client.SetMyValue(1);   //==> returns 1<br>
              client.GetMyValue();    //==> returns 0<br>
              client.SetMyValue(6);    //==> returns 6<br>
              client.GetMyValue();    //==> returns 0<br></p>
  
  <p>Now when I configure my service to use https and transport security with certificate InstanceContextMode.PerSession acts like InstanceContextMode.PerCall. </p>
  
  <p>[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession  )] result for client is now changed:</p>
  
  <p>Service1Client client = new Service1Client();<br>
  client.ClientCredentials.ClientCertificate.SetCertificate(            StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint,            "3d6ca7a6ebb8a8977c958a3d8e4436337b273e4e");<br>
            client.GetMyValue();     //==> returns 0<br>
              client.SetMyValue(1);   //==> returns 1<br>
              client.GetMyValue();    //==> returns 0<br>
              client.SetMyValue(6);    //==> returns 6<br>
              client.GetMyValue();    //==> returns 0<br></p>
  
  <p>My service web.config is:</p>
  
  <pre><code>&lt;bindings&gt;
    &lt;wsHttpBinding&gt;
      &lt;binding name="wsHttpEndpointBinding"&gt;
        &lt;security mode="Transport"&gt;
          &lt;transport clientCredentialType="Certificate"/&gt;
        &lt;/security&gt;
      &lt;/binding&gt;
    &lt;/wsHttpBinding&gt;
  &lt;/bindings&gt;
  
  &lt;services&gt;
    &lt;service behaviorConfiguration="ServiceBehavior" name="WcfServiceLibrary1.Service1"&gt;
      &lt;endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpEndpointBinding"
        name="wsHttpEndpoint" contract="WcfServiceLibrary1.IService1" /&gt;
    &lt;/service&gt;
  &lt;/services&gt;
  
  &lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name="ServiceBehavior"&gt;
        &lt;serviceMetadata httpsGetEnabled="true" httpGetEnabled="false"/&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;   
  </code></pre>
  
  <p>Why PerSession acts like PerCall? What have I misconfigured? </p>