[英]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 当我在servicecontract中使用
SessionMode = SessionMode.Required
,我收到此错误
Contract requires Session, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it.
合同需要Session,但Binding'BasicHttpBinding'不支持它,或者没有正确配置以支持它。
anyone tell me a solution? 有谁告诉我一个解决方案?
随着它的上市在这里 ,选择wsHttpBinding
或NetTcpBinding.WSHttpBinding
结合。
This error message is seldom clear. 此错误消息很少清除。 Here the answer goes like this, basichttpbinding doesn't support session.
答案是这样的,basichttpbinding不支持会话。 So you have to use the below property if you want to use it.
因此,如果要使用它,则必须使用以下属性。 [ServiceContract(SessionMode = SessionMode.Allowed)]
[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. 这意味着,如果您尝试配置多个绑定,如basichttp,wshttp,net.tcp,WCF将自动启用除basichttp绑定之外的会话。 so if you put SessionMode.Required instead of Allowed, then you are forced not to use basichttpbinding.
因此,如果您使用SessionMode.Required而不是Allowed,那么您将被迫不使用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>
.......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.