Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
875 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...