Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically start a C# WebService?

I have written a C# WebService. The problem is that after I publish it to IIS it won't automatically start unless any of its methods is called. This is very frustrating because this WebService has to continuously do some background work immediately after it starts (its constructor executes). If IIS is restarted, the WebService will just sit idly until one of its methods is called. Is there a way to overcome this and force the WebService to execute its constructor immediately after it is published or IIS restarted?

like image 442
hancock Avatar asked Mar 24 '10 08:03

hancock


2 Answers

If It has to continuously do some background work immediately after it starts why not implement this in a Windows service? I think you can write a WCF service which will be hosted in the Windows service. That way clients can still call your service, the service can do its background work and wont be dependent on IIS as the host window service will run on its own process.

like image 151
Ashish Gupta Avatar answered Sep 21 '22 21:09

Ashish Gupta


If you need it to run all the time, your design is flawed. Create a windows service instead.

like image 30
leppie Avatar answered Sep 17 '22 21:09

leppie