c# 操作IIS应用程序池

阅读 87

2022-02-09


直接代码:


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 未找到!");
}
using System.DirectoryServices; // 添加引用 System.DirectoryServices




c# 操作IIS应用程序池_c#_03




作者: ​​王磊的博客​​



精彩评论(0)

0 0 举报