Reputation: 9926
I wrote wcf web service and the host is IIS.
But i want that this web service will be available only when some application ( that i writing ) is running.
Is it possible to have an ability to turn on/off this web service by my application ?
Upvotes: 2
Views: 39
Reputation: 3787
Yes, you can create separate application pool for your web services and start\stop it from your C# code (with enough permissions). There're plenty of ways to do it, I prefer that one:
var directoryEntry = new DirectoryEntry("IIS://YOURWEBSERVER/W3SVC/AppPools/WebServicesAppPool", USERNAME, PASSWORD);
// stop the Application Pool
directoryEntry.Invoke("Stop", null);
// start the Application Pool
directoryEntry.Invoke("Start", null);
Upvotes: 1