如何检测什么应用程序池我目前下运行? (IIS6) [英] How to detect what Application Pool I am currently running under? (IIS6)
本文介绍了如何检测什么应用程序池我目前下运行? (IIS6)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要知道我怎么能到我下运行当前的应用程序池,这样我就可以在上面做一个循环编程。
有谁知道如何吗?IIS6做到这一点。
我目前回收的应用程序池的代码是:
///<总结>
///回收一个应用程序池
///< /总结>
///< PARAM NAME =IIsApplicationPool>< /参数>
公共静态无效RecycleAppPool(字符串IIsApplicationPool){
管理范围范围=新的管理范围(@\\localhost\root\MicrosoftIISv2);
scope.Connect();
的ManagementObject APPPOOL =新的ManagementObject(范围,新ManagementPath(IIsApplicationPool.Name ='W3SVC / AppPools /+ IIsApplicationPool +'),NULL);
appPool.InvokeMethod(回收,NULL,NULL);
}
解决方案
和搜索之后,我找到了回答自己:
公共字符串GetAppPoolName(){
串APPPATH = Context.Request.ServerVariables [ APPL_MD_PATH];
APPPATH = AppPath.Replace(/ LM /,IIS://本地主机/);
的DirectoryEntry根=新的DirectoryEntry(APPPATH);
如果((根== NULL)){
返回没有对象了;
}
串AppPoolId =(字符串)root.Properties [AppPoolId]值。
返回AppPoolId;
}
嗯。他们需要一种方法来让我把我自己的答案的答案。
I need to know how I can detect the current application pool I am running under, so I can do a Recycle on it programmatically.
Does anyone know how to do this for IIS6?
My current code for recycling the app-pool is:
/// <summary>
/// Recycle an application pool
/// </summary>
/// <param name="IIsApplicationPool"></param>
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);
}
解决方案
And after searching I found the answer myself:
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;
}
Hmm. They need a way to let me set my own answer as THE answer.
这篇关于如何检测什么应用程序池我目前下运行? (IIS6)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文