I currently have a service in WCF where it processes requests made by a client. However, it caches some data that the client sends it. It then does computations on the data.
At any point the client should be able to retrieve some of the data. It is at the discretion of the user (when a Button is clicked, an AJAX query is sent to get some of the data).
The problem I'm having is that as soon as another client connects, and starts sending requests, the data that the original client sent is now distorted.
I was wondering how I can resolve this. I've attempted to use sessions, as I was looking for some way I can instantiate my "server object" for each client that wants to connect to it. Still no luck.
This question is related to this: WCF Closing a connection/Releasing resources
Sounds like maybe you're looking for a WCF Durable Service (link). Durable services can keep state between calls to a service.
Chapter 4 in Juval Lowy's Programming WCF Services (link) also has information about Durable Services as well as per-session services which might also help.
In general, though, it's considered good practice to make your WCF services stateless - i.e. don't hold onto any state between calls. Durable services accomplish this by persisting data, for example to a database between calls instead of actually keeping it in memory (which could be a bad thing if you have thousands of simultaneous service consumers).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With