Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Contract requires Session, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it

Tags:

wcf

When i'm using SessionMode = SessionMode.Required in servicecontract then i get this error

Contract requires Session, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it.

anyone tell me a solution?

like image 358
Vikram Avatar asked Dec 10 '10 08:12

Vikram


1 Answers

This error message is seldom clear. Here the answer goes like this, basichttpbinding doesn't support session. So you have to use the below property if you want to use it. [ServiceContract(SessionMode = SessionMode.Allowed)]

This means, If you are trying to configure multiple bindings like basichttp, wshttp, net.tcp, WCF will automatically enable session for other than basichttp binding. so if you put SessionMode.Required instead of Allowed, then you are forced not to use basichttpbinding.

That said, solving this issue usually would require something like this:

<system.serviceModel>
    <protocolMapping>
      <add scheme="http" binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfiguration" />
    </protocolMapping>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpBindingConfiguration" transactionFlow="true" />
      </wsHttpBinding>
      .......
like image 105
Jeya Prakash A Avatar answered Sep 21 '22 07:09

Jeya Prakash A