InstanceContextMode.PerSession not working in IIS hosted service

Hello,
I have simple wcf service hosted in IIS 7. The fist call to the service (GetData) creates the Transaction object. I expected that the 2nd call to the service (GetData2) would have the Transaction object available. However the value of MyTrans is null on the 2nd call.   I thought that     [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]  would result in this object being retained for the session. Any idea what I am doing wrong ?

regards
Pat

Service code:
   [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
   public class Service1 : IService1
    {
        Transaction MyTrans;
        public Transaction GetData(string value)
        {
            MyTrans = new Transaction();
            MyTrans.companyId="CCS Ltd";
            MyTrans.trans = "Initmenu01";
            MyTrans.userId = "PClarkeirl";
            MyTrans.curSeq = 123;
            return MyTrans;
        }

        public Transaction GetData2(string value)
        {
            MyTrans.nextSeq = MyTrans.nextSeq+1;
            return MyTrans;
        }


Client code:

        {
           
                ServiceReference2.Service1Client client = new ServiceReference2.Service1Client();
                ServiceReference2.Transaction MyClientTrans = client.GetData("XXX");
                MyClientTrans = client.GetData2("XXX");
        }



web.config source
<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- 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. -->
  <system.serviceModel>
    <services>
      <service name="WcfServiceLibrary7.Service1">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary7/Service1/" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address="" binding="basicHttpBinding" contract="WcfServiceLibrary7.IService1">
          <!--
              Upon deployment, the following identity element should be removed or replaced to reflect the
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information,
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
          <!-- 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 -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>
LVL 1
pclarke7Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

pclarke7Author Commented:
Dissapointing that there were no answers received for this question,
however for anyone reading this I figured out why the perSession was not working. It seems that perSession is not handled by BasicHttpBinding. I have to change the binding to WsHttpBinding. Once I did this then the data was retained.

regards
Pat
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pclarke7Author Commented:
Sorted this one out myself as there was zero response to the question
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.