WCF Service hosted in IIS - Can't seem to cache or retain state?

Asked
Viewd1037

0

I'm trying to cache some application data that only needs to be instantiated when the application starts. I've tried using HttpRuntime.Cache, creating a static object that is instantiated only when the service starts, and I've tried making the service singleton and using global variables. Every time a new request hits the service I loose state... I could create the WCF service as a windows service I suppose, but I'd love to figure out what's happening here... I see that only one IIS worker process is spawning, but I'm guessing it's unloading and re-loading the service every time.

Am I missing some WCF configuration or possibly not setting it up right in IIS? It's running as a normal 2.0 website within IIS.

This my first post here, if someone can tell me how to post my app.config XML I will... I think stackoverflow is trying to parse it as HTML, it doesn't show up.

Thank you! Tim

  • Did you know that WCF is not built on top of ASP.NET?

    John Saunders31 июля 2009, 19:03

1 ответов

0

We use enterprise library caching with WCF services, works for us:

http://msdn.microsoft.com/en-us/library/dd203099.aspx

Edit

This answer is a bit old we have now stopped using Enterprise Library Caching, we use app fabric instead, see: http://msdn.microsoft.com/en-us/windowsserver/ee695849