如何确定在C#中运行SharePoint服务应用程序的应用程序池?

时间:2012-10-02 21:39:55

标签: c# sharepoint sharepoint-2010

有没有办法以编程方式确定运行服务应用程序的应用程序池?到目前为止,我还没有真正发现这一点。任何帮助表示赞赏!

3 个答案:

答案 0 :(得分:1)

IIS将应用程序分配给应用程序池。我不知道以编程方式还是通过配置更改应用程序池的方法。

编辑:我认为这看起来有可能,本文可以帮助您: Setup IIS programmaticaly

答案 1 :(得分:1)

这是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)

复制

答案 2 :(得分:0)

有人向我提供了特定于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;
        }
    }
}
相关问题