I have an ASP.NET Web Forms site. I am trying to get the HTTP Bindings from IIS8 programatically, but coming up with a problem. It is failing on the following line:
// Get the sites section from the AppPool.config
Microsoft.Web.Administration.ConfigurationSection sitesSection = Microsoft.Web.Administration.WebConfigurationManager.GetSection(null, null, "system.applicationHost/sites");
The error is:
The filename, directory name, or volume label syntax is incorrect. (Exception from HRESULT: 0x8007007B)
Interestingly, the following line identifies the correct web.config file. (I know the bindings aren't located in here, but I did this just to see if it can access other config files)
var configFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
Does anyone know why this would be happening? Any advice will be appreciated! Thanks!
User contributions licensed under CC BY-SA 3.0