Reputation: 6477
I've created a WCF service in which I would like it to maintain state between calls from the client. I figured the easiest way to do this was to add this attribute to the service:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
since this is supposed to keep a separate service alive for each client over the life of the client proxy (or timeout in the extreme case). I also added a test function that tracks a list of user inputs, and spits out a concatenated string with all the inputs over the life of the service.
When I run this in the test client generated by visual studio, I find that the list I was using to hold past data is reset with each call. Is there something else I need to do to maintain state per session?
Upvotes: 0
Views: 2016
Reputation: 6477
Ok figured it out. I was using a BasicHttpBinding, which doesn't support per session instancing. I switched it to a wsHttpBinding, and presto, everything works.
Upvotes: 2