16

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?

Patrick D'Souza
  • 3,491
  • 2
  • 22
  • 39
Vikram
  • 485
  • 2
  • 8
  • 13

2 Answers2

12

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>
      .......
daniloquio
  • 3,822
  • 2
  • 36
  • 56
Jeya Prakash A
  • 129
  • 1
  • 3
10

As it's listed here, choose wsHttpBinding or NetTcpBinding.WSHttpBinding binding.

Ben
  • 1,023
  • 9
  • 10
  • I used the solution but the problem didn't go away and then I found one more thing to do [here](http://stackoverflow.com/questions/4930403/basic-http-binding-isnt-configured-properly) so don't forget to add this to your config... – Mochi May 27 '14 at 14:27