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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With