Why Creating new session id every time in wsHttpBinding

423 Views Asked by At

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>
1

There are 1 best solutions below

0
On BEST ANSWER

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;
  }