WCF Service Life Cycle Hosted in IIS

The question is about static data in the class.

If this is a class of service, I think the instantiation mode is important. But what happens if I have a separate, standalone singleton class?

Can I create an object there that will be available for all calls on each call? Does IIS have this dll in memory forever, so the singleton will be in memory all the time?

How can I make some object available to all WCF client calls? Is it possible to do this in IIS or should I host the WCF service in a windows service?

+5
source share
2 answers

Verified issue in local IIS.

This is my code.

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] 
public class Service : IService
{

    public static int _counter = 0;

    public string GetData()
    {
        _counter++;
        return _counter.ToString();
    }
}

IIS , , . .

, InstanceContextMode . InstanceContext.

, - . IIS "Web Garden". , , .

http://www.iis.net/ConfigReference/system.applicationHost/applicationPools

WCF-? IIS WCF windows?

, . IIS - , , Windows, .

+2

,

  • , , WCF. ( IIS Windows) .

  • " " , (/ ..)?

  • , "Durable WCF services" ( ). - , , , .

, .

+2

All Articles