I'm attempting to remove a credit card applicatoin in the default site in IIS7 throughout uninstallation. Here's my code which doesn't work:

Microsoft.Web.Administration.ServerManager iisManager

iisManager = new Microsoft.Web.Administration.ServerManager()

Microsoft.Web.Administration.Site defaultSite

defaultSite = iisManager.Sites["Default SiteInch]

Microsoft.Web.Administration.Application myApplication

myApplication = defaultSite.Programs["MyApplication"]

defaultSite.Programs.Remove(myApplication )

iisManager.CommitChanges()

What's the proper way to do that?

Thanks

This will have the desired effect:

using (ServerManager serverManager = new ServerManager())

Programs["/MyApplication"]

    site.Programs.Remove(application)

    serverManager.CommitChanges()



The code does result in the presumption that you're removing the applying /MyApplication in the cause of the Default Site (IIS number #1).