//method是管理应用程序池的方法,有三种Start、Stop、Recycle,而AppPoolName是应用程序池名称
//应用程序池网络用户需改为本地用户
static void ConfigAppPool(string method, string AppPoolName)
{
DirectoryEntry appPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools", "Administrator", "password");
DirectoryEntry findPool = appPool.Children.Find(AppPoolName, "IIsApplicationPool");
findPool.Invoke(method, null);
appPool.CommitChanges();
appPool.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
ConfigAppPool("Start", "GacAppPool");
ConfigAppPool("Stop", "GacAppPool");
ConfigAppPool("Recycle", "GacAppPool");
}
停止IIS服务
ServiceController sc = new ServiceController("iisadmin");
if(sc.Status=ServiceControllerStatus.Running)
sc.Stop();
重启IIS服务
ServiceController sc = new ServiceController("iisadmin");
sc.Start();
重启进程
using System.Diagnostics;
Process.Start("iisreset");
更新应用程序:
1、bin
2、web.config
3、回收应用程序池(29小时)
4、global.ascx
5、app_code文件夹
6、asp.net页面(15次?)