简体   繁体   English

如何在IIS7中获取与应用程序池关联的应用程序

[英]How to get applications associated with a application pool in IIS7

I have a virtual directory name. 我有一个虚拟目录名称。 For this virtual directory i have to find out the application pool associated. 对于这个虚拟目录,我必须找出相关的应用程序池。 Once i get the application pool i have to find out all the virtual directories on this application pool.. I am using this code to find out the application pool associated with virtual directory 一旦我获得应用程序池,我必须找出此应用程序池中的所有虚拟目录..我使用此代码找出与虚拟目录关联的应用程序池

string AppPoolName = string.Empty;
            ServerManager manager = new ServerManager();
            foreach (Site site in manager.Sites)
            {
                foreach (Application app in site.Applications)
                {
                    string path = app.Path;
                    path = path.Replace("/", " ");
                    path = path.Trim();

                    if (path.ToLower() == VDName.ToLower())
                    {
                        AppPoolName = app.ApplicationPoolName;
                        break;
                    }
                }
            }
using (var serverManager = new ServerManager())
{
    var apps = (from site in serverManager.Sites
                from app in site.Applications
                where app.ApplicationPoolName.Equals("DefaultAppPool")
                select app);
}

I think we have to rerun the function for application pool to get the name for applications associated. 我认为我们必须重新运行应用程序池的功能以获取相关应用程序的名称。

 ServerManager manager = new ServerManager();
        foreach (Site site in manager.Sites)
        {
            foreach (Application app in site.Applications)
            {

                if (app.ApplicationPoolName.ToString() == AppPoolName)
                {
                     string appname = app.Path;
                }
            }
        }

或者新线没有循环方法:

 Environment.GetEnvironmentVariable("APP_POOL_ID", EnvironmentVariableTarget.Process);

May be this link will give you hints to develop your code 可能是这个链接将为您提供开发代码的提示

Restarting (Recycling) an Application Pool 重新启动(回收)应用程序池

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 以编程方式停止应用程序池问题IIS7 - STOP Application Pool Issue Programmatically IIS7 使用C#回收IIS7应用程序池 - Recycle IIS7 Application Pool with C# 如何获得与应用程序池关联的应用程序/站点的数量(可能还有名称)? - How can you get the number (and possibly names) of applications / sites associated with an application pool? 使用 csharp 检查状态应用程序池 iis7(拒绝访问) - check status application pool iis7 with csharp (access-denied) IIS7以编程方式在ASP.NET中获取应用程序池版本 - IIS7 Programmatically get App Pool version in ASP.NET 您可以将IIS7配置为在启动/回收应用程序池时自动启动Windows进程激活服务(WAS)应用程序吗? - Can you configure IIS7 to autostart a Windows Process Activation Service (WAS) application when the application pool starts/recycles? 如何在iis7中以编程方式完成应用程序的url授权? - How to programatically accomplish url authorization in iis7 for an application? 从IIS6-IIS7获取应用程序池版本 - get Application pool version from IIS6-IIS7 如何在IIS实例中的所有应用程序/虚拟目录/版本之间共享Oracle连接池? - How can I get an Oracle connection pool shared across all applications/virtual directories/versions in my IIS instance? 在哪里可以学习如何将ASP.NET 4 MVC 2应用程序部署到IIS7? - Where can I learn how to deploy ASP.NET 4 MVC 2 applications to IIS7?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM