How IIS control WCF lifetime service wiith InstanceContextmode set to single?

98 Views Asked by At

I developed WCF service with InstanceContextmode set to single and hosted by IIS. Periodically, the service is probably restarted by IIS. How can we adjust the way IIS manages the lifetime of this service in singleinstance mode?

2

There are 2 best solutions below

0
On

I highly recommend you not to host your WCF service inside IIS. There is a simple and minimal way to self-hosting. By self-hosting, I mean that your WCF app hosted itself inside ITSELF. Here is a good sample code for that: https://github.com/amiru3f/ws-security After self-hosting, you can simply create a windows service with nssm to ignore deprecated weak IIS.

0
On

You can try the following methods:

Click Settings in the operation box on the right side of IIS.enter image description here

Change Startmode from Ondemand to alwaysrunning. enter image description here

Then set up the hosted wcf service, enter Advanced settings and set preload enabled to true. enter image description here