如果我想使用 Microsoft.Web.Administration,相当于 IISReset 的是什么
看起来,除了迭代 ApplicationPools 并对其调用 Recycle() 之外,还涉及更多内容。如何以编程方式(来自 .Net)最接近地模仿 IISReset,而不诉诸 shell 调用?
我认为最重要的是: IISReset 所做的事情是否无法通过 Microsoft.Web.Administration 命名空间中提供的工具来完成?
It would appear that there is more involved than just iterating the ApplicationPools and calling Recycle() on them. How do I most closely mimic an IISReset programatically (from .Net) without resorting to shell invocation?
And I suppose most importantly: Are there things that IISReset does that can't be accomplished via the tools available in Microsoft.Web.Administration namespace?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 System.ServiceProcess.ServiceController (从这个 答案),通过启动或停止以下服务:
-Windows 进程激活服务 (WAS)
- 万维网发布服务 (W3SVC)
以下是一些可以完成这项工作的代码:
至于其他 IISReset 命令,您可以轻松地编写超时代码。要重新启动计算机,请查看此答案。如果您需要更多详细信息,请告诉我。
但是,如果这对您来说还不够,您始终可以使用 这个技巧(漂亮的球手,如果你只需要完成任务)。
You can use System.ServiceProcess.ServiceController (got the idea from this answer), by starting or stopping the following services:
-Windows Process Activation Service (WAS)
-World Wide Web Publishing Service (W3SVC)
Here's some code that'll do the job:
As for other IISReset commands, you could code in a timeout easily enough. And to reboot the computer, check out this answer. Let me know if you need any more details.
But if that's not enough of a party for ye, you can always execute power shell scripts in c#, using this technique (pretty baller, if you just need to get 'er done).