0

I am using following configuration to make my service sessionful, but for each request wcf service is responding me with new session id. Why it so, what I need to make it sessionful for that client so that for each request there should be same session id

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttp">
          <readerQuotas maxStringContentLength="10240" />
          <reliableSession enabled="true" />          
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>                  
      <service name="wcfservice.serviceclass" behaviorConfiguration="MyFileServiceBehavior">

        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:51/"/>
            <add baseAddress="net.tcp://localhost:52/"/>
          </baseAddresses>          
        </host>
        <endpoint address="pqr" binding="wsHttpBinding" bindingConfiguration="wsHttp"
          name="b" contract="wcfservice.Iservice" />
        <endpoint address="pqr" binding="netTcpBinding" 
          name="c" contract="wcfservice.Iservice" />      
      </service>
    </services>   
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyFileServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />              
        </behavior>
      </serviceBehaviors>
    </behaviors>

  </system.serviceModel>
funsukvangdu
  • 1,621
  • 4
  • 20
  • 33
  • Do you have `SessionMode = SessionMode.Required` on your ServiceContractAttribute? – Simon Taylor Nov 16 '14 at 01:37
  • It is sessionmode.allowed – funsukvangdu Nov 16 '14 at 14:16
  • Set session mode to required, so it throws an exception when something is wrong, after fixing everything, you can change it back to allowed. Add following information to your question, sample code of your client which calls your service, and the network configuration, any physical load balancing mechanisem , firewalls(both hardware & software based models) and proxy servers. – Yaser Moradi Nov 21 '14 at 07:31

1 Answers1

0

By default a session is initiated when channel is opened you can read more about it here in this Sessions in WCF

AS the default value of IsInitiating parameter is true each of your calls started a new session. Read more About it here IsInitiating and IsInitiating

So in your Operation contracts

[OperationContract(
    IsInitiating=false,
    IsTerminating=false
  )]
  public void MethodOne()
  {
    return;
  }