6

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

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Mubashar
  • 12,300
  • 11
  • 66
  • 95

3 Answers3

8

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>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • I have tried this before but it throws exception that says "No base address found with http scheme bla bla and reliableSessions are not support with https scheme bla bla" – Mubashar Apr 16 '10 at 07:22
  • What can I do if I want to use sessions but I can't do as you suggested since my client is AJAX? since AJAX doesn't support the security context. – Dor Cohen Dec 06 '12 at 14:46
  • 7
    This answer is incorrect. Reliable Sessions() cannot be used with SSL (). – toadflakz May 24 '13 at 14:59
  • when i try to use your solution it throws an other exception about not finding HTTPs base address? – Mumin Asaad Sep 30 '14 at 14:14
  • What is " the security sessions" referring to? What is that? – Stealth Rabbi Mar 02 '19 at 01:11
-1

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

user1312242
  • 339
  • 1
  • 3
  • 16
-1

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