我需要知道如何检测我正在运行的当前应用程序池,因此我可以通过编程方式对其进行回收.
有谁知道如何为IIS6做这个?
我目前用于回收应用程序池的代码是:
////// Recycle an application pool /// /// public static void RecycleAppPool(string IIsApplicationPool) { ManagementScope scope = new ManagementScope(@"\\localhost\root\MicrosoftIISv2"); scope.Connect(); ManagementObject appPool = new ManagementObject(scope, new ManagementPath("IIsApplicationPool.Name='W3SVC/AppPools/" + IIsApplicationPool + "'"), null); appPool.InvokeMethod("Recycle", null, null); }
Wolf5.. 7
搜索后我自己找到了答案:
public string GetAppPoolName() { string AppPath = Context.Request.ServerVariables["APPL_MD_PATH"]; AppPath = AppPath.Replace("/LM/", "IIS://localhost/"); DirectoryEntry root = new DirectoryEntry(AppPath); if ((root == null)) { return " no object got"; } string AppPoolId = (string)root.Properties["AppPoolId"].Value; return AppPoolId; }
嗯.他们需要一种方法让我把自己的答案作为答案.
搜索后我自己找到了答案:
public string GetAppPoolName() { string AppPath = Context.Request.ServerVariables["APPL_MD_PATH"]; AppPath = AppPath.Replace("/LM/", "IIS://localhost/"); DirectoryEntry root = new DirectoryEntry(AppPath); if ((root == null)) { return " no object got"; } string AppPoolId = (string)root.Properties["AppPoolId"].Value; return AppPoolId; }
嗯.他们需要一种方法让我把自己的答案作为答案.