Shared Storage?
-
Hello, i'm new in developing with WCF Services and WebServices generally. I wan't to develop a simple WCF Service, where i have a list of "online users". As i started the application it all worked fine, until i logged on with a second user. It seems, that the IIS Server creates a WCF-Service Instance for each connection. How can i create a List, Array or something else, which i can use globally over all instances? I don't want to use a database or something else, just to store a few parameters globally. Is there any solution fot this problem? Thank you
-
Hello, i'm new in developing with WCF Services and WebServices generally. I wan't to develop a simple WCF Service, where i have a list of "online users". As i started the application it all worked fine, until i logged on with a second user. It seems, that the IIS Server creates a WCF-Service Instance for each connection. How can i create a List, Array or something else, which i can use globally over all instances? I don't want to use a database or something else, just to store a few parameters globally. Is there any solution fot this problem? Thank you
Hello, WCF allows 3 instancing modes. Your service uses PerCall instancing at the moment (I guess you are using BasicHttpBinding). You can create singleton service. Instance of singleton service will handle all request from all clients. To use singleton service, mark your service implementation (class implementing service contract) with following attribute:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class MyService : IMyService
{
...
}There is another configuration which you can check: ConcurrencyMode (also set in ServiceBehaviorAttribute). ConcurrencyMode controls how many requests can be served by the service instance at same time. Default is Single so only one client request will be served by your singleton service at the same time. Other clients will wait in "queue" until server or timeout. Best regards, Ladislav