C#代码启动和停止IIS 7服务器中的特定应用程序池 [英] C# Code to Start and stop perticular application pool in IIS 7 server

查看:134
本文介绍了C#代码启动和停止IIS 7服务器中的特定应用程序池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在编写一个C#应用程序的任务,该应用程序启动和停止IIS 7服务器的应用程序池。任何人都可以知道我们是否可以编写一个代码来停止并启动作为输入给出的特定应用程序池。



另外,请告诉我是否也可以远程执行上述操作。

提前付款

Prashant

Hi All,

I am having a task to write a C# application which starts and stops the application pool of IIS 7 server. Can any one have the Idea whether we can write a code which stops and starts the perticular app pool given as input.

Also, Please tell me whether we can do the above opertion remotely also.
Thanks in advance
Prashant

推荐答案

这里我们回答成员在编程时遇到的具体问题。



我们无法工作在整个源代码上。你需要自己做。



如果你在编码时遇到任何困难,请随时回到这里,并提出另一个问题来描述这个场景。各位会员很乐意为您提供帮助。
Here we answer specific questions which members face during programming.

We can't work on the whole source code. You need to do that yourself.

If you face any difficulty while coding, feel free to come back here and ask another question with specific issue describing the scenario. Members will be happy to help you then.


您需要参考System.DirectoryService。然后使用以下代码



You need to take reference of System.DirectoryService. Then use the following code

 string appPoolPath = "IIS://localhost/W3SVC/AppPools/myapppool";
//localhost will be actual server name.
            var appPool = new DirectoryEntry(appPoolPath);
            appPool.Invoke("Start", null);
            appPool.Invoke("Stop", null);
            appPool.Invoke("Recycle", null);





请记住,执行此代码需要管理权限。



Just remember that administrative permission is needed to execute this code.


这篇关于C#代码启动和停止IIS 7服务器中的特定应用程序池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆