1

I am trying to use session in my WCF service (webHttp), but the session is not consistent between requests (When I make the second call to the service the session is not NULL, but the key I inserted doesn't exist and the session ID is different).

I checked and the default InstanceContextMode is PerSession, which as I understand should be suitable for my requirements.

Are there any other configurations I need for using session in WCF?

Thanks!

SuperFrog
  • 7,631
  • 9
  • 51
  • 81

1 Answers1

3

You need to use a binding that supports reliable sessions, such as these:

  • HTTP-based transport standard bindings:

    WsHttpBinding and expose request-reply or one-way contracts.

    Can be used when using reliable session over a request-reply or simple one-way service contract.

    WsDualHttpBinding and expose duplex, request-reply, or one-way contracts.

    WsFederationHttpBinding and expose request-reply or one-way contracts.

  • TCP-based transport standard bindings:

    NetTcpBinding and expose duplex, request reply, or one-way contracts.

Look here for more info: http://msdn.microsoft.com/en-us/library/ms733136.aspx

Garrett Vlieger
  • 9,354
  • 4
  • 32
  • 44
  • Sessions and reliable sessions are not the same thing. A session is simply a mechanism that the service uses to understand multiple messages are coming form the same proxy. It doesn't say anything about tracking a sequence of messages. Reliable sessions is an implementation of WS-ReliableMessaging. As it turns out of course, you can't implement WS-ReliableMessaging unless you know that the messages have come from the same client (in fact WSHttpBinding can use WS-ReliableMessaging to implement its notion of WCF session although by default, if available, it uses WS-SecureConversation) – Richard Blewett Aug 03 '12 at 07:30