首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >c# 操作IIS应用程序池

c# 操作IIS应用程序池

作者头像
磊哥
发布于 2018-04-26 16:58:21
发布于 2018-04-26 16:58:21
1.6K0
举报
文章被收录于专栏:王磊的博客王磊的博客

直接代码:

代码语言:javascript
复制
using System.DirectoryServices; // 添加引用 System.DirectoryServices

try
{
    DirectoryEntry appPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
    DirectoryEntry findPool = appPool.Children.Find("DefaultAppPool", "IIsApplicationPool");
    findPool.Invoke("Start", null);     // Start|Stop|Recycle [Recycle:应用程序池回收,如果状态为Stop会报错]
    appPool.CommitChanges();
    appPool.Close();
    Response.Write("DefaultAppPool 操作成功!");
}
catch (Exception ex)
{
    Response.Write("DefaultAppPool 未找到!");
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2011-01-11 ,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档