简体   繁体   中英

Why Creating new session id every time in wsHttpBinding

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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM