I am trying to access system.webServer/defaultDocument in my web.config file but can’t seem to find out how. I have tried various articles about editing the web config file but I don’t seem to have the same options to access the items in system.webServer as I would if I was changing a connectionString for instance.
I can load the system.webServer section using:
ConfigurationSection WebServerSection = (ConfigurationSection)WebConfigurationManager.GetSection("system.webServer");
but can’t see to find anything usable from that point. One thing I have noticed is that the system.webServer section is of type System.Configuration.IgnoreSection. Does this somehow stop me having access to edit it?
Take a look the Microsoft.Web.Administration API, it offers a WebConfigurationManager class that should allow you to access the content of the webServer section: