how to enable WCF Session with wsHttpBidning with

2020-01-29 07:29发布

I have a WCF Service currently deployed with basicHttpBindings and SSL enabled. But now i need to enable wcf sessions(not asp sessions) so i moved service to wsHttpBidnings but sessions are not enabled

I have set

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]

But when i set

SessionMode=SessionMode.Required

on service contract it says

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

following is the definition of WSHttpBinding

<wsHttpBinding>
    <binding name="wsHttpBinding">
      <readerQuotas maxStringContentLength="10240" />
      <reliableSession enabled="false" />
      <security mode="Transport">
        <transport clientCredentialType="None">
          <extendedProtectionPolicy policyEnforcement="Never" />
        </transport>
      </security>
    </binding>
  </wsHttpBinding>

please help me with this

3条回答
仙女界的扛把子
2楼-- · 2020-01-29 07:52

If you want "sessions" with wsHttpBinding, you have to use either reliable messaging, or the security sessions.

To enable sessions on wsHttpBinding, you need reliable messaging, and for that, you need to change the setting for reliable session (the tag that looks like this <reliableSession/>) to be enabled - so your new config would look like this:

<wsHttpBinding>
    <binding name="wsHttpBinding">
      <readerQuotas maxStringContentLength="10240" />
      <reliableSession enabled="true" />
      <security mode="Transport">
        <transport clientCredentialType="None">
          <extendedProtectionPolicy policyEnforcement="Never" />
        </transport>
      </security>
    </binding>
  </wsHttpBinding>
查看更多
趁早两清
3楼-- · 2020-01-29 07:54

well make <security mode="None"> then the "Https expected instead of HTTP error will be fixed.

查看更多
叼着烟拽天下
4楼-- · 2020-01-29 07:54

go to your IIS host and Right Click on your Application and choose MangeApplication and Advanced Settings and in Enabled Protocols add "wsHttpBinding".

查看更多
登录 后发表回答