如何在IIS7中获取与应用程序池关联的应用程序 [英] How to get applications associated with a application pool in IIS7

查看:145
本文介绍了如何在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;
                    }
                }
            }


推荐答案

我认为我们必须重新运行应用程序池的功能才能获取相关应用程序的名称。

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;
                }
            }
        }

这篇关于如何在IIS7中获取与应用程序池关联的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆