开发者

How to Maintain per-Client State in a WCF Service?

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开发者_JS百科 session?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜