I have a WCF that has a static class. I use this to store login information. To my great surprise I am finding that at different times the wcf static is losing values. What could cause this? What is the best way to persist information in a WCF service? In memory is the best because it is faster...
+1
A:
If the hosting application domain is restarted all static values stored in memory will be lost. For example in IIS the application could be unloaded by the web server.
The only solution to this is to save the values into a persistent storage instead of using static fields.
Darin Dimitrov
2010-10-17 15:41:43
A:
There are several possibilities:
- Something in your code is deleting the values
- The applicaion pool is being recyled, you then loose everything in memory
You can set the options for the application pool only to recycle at certain times.
If you need to keep the login information you should store it to a file on disk or preferably to a database.
Shiraz Bhaiji
2010-10-17 15:45:12