是否有可能启动/停止IIS编程的应用程序池或网站?有可能、应用程序、网站、IIS

2023-09-04 01:42:43 作者:╰っ冷暖自知

我试图找到一种方法,停止,启动,从在同一个服务器上的Web界面重新启动/循环利用网站和应用程序池。理想情况下,这将是东西,我可以做.NET,而无需执行shell命令。

I'm trying to find a way to stop, start, restart/recycle websites and application pools from within a web interface on the same server. Ideally this would be something I could do with .NET without having to execute shell commands.

(我看其他的相关问题已经问,但我不希望在命令行中执行此操作,除非这是必要的)。

(I see other related questions have been asked but I don't want to do this from the command line unless that's necessary).

我需要能够做到这一点为IIS6和IIS7。

I need to be able to do this for both IIS6 and IIS7.

推荐答案

您正在寻找的 Microsoft.Web.Administration.ServerManager 类。你可以在这里找到一些入门code: http://learn.iis.net /page.aspx/226/microsoftwebadministration/ 。

You are looking for the Microsoft.Web.Administration.ServerManager class. You can find some starter code here: http://learn.iis.net/page.aspx/226/microsoftwebadministration/.

您可以探索code进一步做你想要什么。我相信整个 APPCMD 是写在这个框架之上。

You can explore that code further to do what you want. I believe the whole appcmd is written on top of this framework.

这个框架将不会为IIS6及以下工作。你需要IIS7。对于II6你可以使用WMI的方法所建议的穆罕默德Aras的。这是不幸的,但你需要这两个库;或者有一些code,在那里,抽象这些库。

This framework will not work for IIS6 and below. You need IIS7. For II6 you could use the WMI approach as suggested by Mehmet Aras. It is unfortunate, but you need these two libraries; or maybe there is some code out there that abstracts these libraries.