是否有可能某些应用程序将打开/关闭由iis托管的web服务?



我写的是wcf web service,主机是IIS
但是我希望这个web服务只有在某些应用程序(我正在编写)运行时才可用。

是否有可能通过我的应用程序打开/关闭此web服务?

是的,你可以为你的web服务创建单独的应用程序池,并在你的c#代码中启动/停止它(有足够的权限)。有很多方法可以做到这一点,我更喜欢这个:

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);

最新更新