I want to be able to check if an application exists within an existing website but I've not found anything. At the moment I have an installer project that gets the input from the user for the name of an existing website. I use this to check the site currently exists in IIS, and if so I then want to search the existing applications to see if a particular 1 exists. Here's what I have:
private void CheckWebsiteApps()
{
SiteCollection sites = null;
try
{
//Check website exists
sites = mgr.Sites;
foreach (Site s in sites)
{
if (!string.IsNullOrEmpty(s.Name))
{
if (string.Compare(s.Name, "mysite", true) == 0)
{
//Check if my app exists in the website
ApplicationCollection apps = s.Applications;
foreach (Microsoft.Web.Administration.Application app in apps)
{
//Want to do this
//if (app.Name == "MyApp")
//{
// Do Something
//}
}
}
}
}
}
catch
{
throw new InstallException("Can't determine if site already exists.");
}
}
Obviously app.Name doesn't exist, so what can I do to get this?