更新时间:2021-09-05 03:11:54
protected void StartStopRecycleApp(string method) { string AppPoolName = this.tbAppName.Text.Trim(); //string method = "Recycle"; try { DirectoryEntry appPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools"); DirectoryEntry findPool = appPool.Children.Find(AppPoolName, "IIsApplicationPool"); findPool.Invoke(method, null); appPool.CommitChanges(); appPool.Close(); lbMsg.Text = string.Format("应用程序池{0}{1}成功", AppPoolName, method); } catch (Exception ex) { lbMsg.Text = string.Format("应用程序池{0}{2}失败:{1}", AppPoolName, ex.Message, method); } }