【发布时间】:2012-10-02 21:39:54
【问题描述】:
有没有办法以编程方式确定服务应用程序在哪个应用程序池上运行?到目前为止,我还没有真正找到太多。任何帮助表示赞赏!
【问题讨论】:
标签: c# sharepoint sharepoint-2010
有没有办法以编程方式确定服务应用程序在哪个应用程序池上运行?到目前为止,我还没有真正找到太多。任何帮助表示赞赏!
【问题讨论】:
标签: c# sharepoint sharepoint-2010
IIS 将应用程序分配给应用程序池。我不知道以编程方式或通过配置更改应用程序池的方法。
编辑:我收回它,看起来这是可能的,这篇文章可能会帮助你: Setup IIS programmaticaly
【讨论】:
这是 IIS6 的示例代码,我不确定它是否适用于 Sharepoint 或其他版本的 IIS...
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;
}
复制自How to detect what Application Pool I am currently running under? (IIS6)
【讨论】:
有人向我提供了特定于 SharePoint 的答案 here,但感谢大家的意见。以下代码是我获取应用程序池的方式:
foreach (SPService service in SPFarm.Local.Services)
{
if (service.Name.Equals("ServiceName"))
{
foreach (SPServiceApplication serviceApp in service.Applications)
{
SPIisWebServiceApplication webServiceApp = (SPIisWebServiceApplication) serviceApp;
SPIisWebServiceApplicationPool appPool = webServiceApp.ApplicationPool;
}
}
}
【讨论】: