It is easy to set settings in the web.config by typing them into the xml file. However, I would like set some settings at runtime.
Specifically I want to set the system.web/httpRuntime/WaitChangeNotification setting.
I’ve tried this, but it throws an error which says the configuration is readonly.
var section = HttpContext.Current.GetSection("system.web/httpRuntime") as System.Web.Configuration.HttpRuntimeSection;
section.WaitChangeNotification = 6;
It’s not a good idea, but this is entirely possible using reflection.
Here is a code example of injecting a Soap extension into the web services section of the app config:
Obviously this is not retrospective so it will only affect values pulled out of the config after it’s been done.
…and once again, you probably don’t want to do this, but it is possible.