How to get applications associated with a application pool in IIS7

后端 未结 3 570
轮回少年
轮回少年 2020-12-17 05:01

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 vi

相关标签:
3条回答
  • 2020-12-17 05:30

    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;
                    }
                }
            }
    
    0 讨论(0)
  • 2020-12-17 05:38
    using (var serverManager = new ServerManager())
    {
        var apps = (from site in serverManager.Sites
                    from app in site.Applications
                    where app.ApplicationPoolName.Equals("DefaultAppPool")
                    select app);
    }
    
    0 讨论(0)
  • 2020-12-17 05:50

    Or a new line no looping approach:

     Environment.GetEnvironmentVariable("APP_POOL_ID", EnvironmentVariableTarget.Process);
    
    0 讨论(0)
提交回复
热议问题