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:
WebConfigurationManager.GetSection(HttpContext.Current,
"system.webServer/defaultDocument");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.