How get web config location element?
ConfigurationManager.GetSection("appSettings") returns Okay
ConfigurationManager.GetSection("location") return null
I.E. ...
<location path="FOLDER/Page2.aspx">
...
</location>
How get web config location element?
ConfigurationManager.GetSection("appSettings") returns Okay
ConfigurationManager.GetSection("location") return null
I.E. ...
<location path="FOLDER/Page2.aspx">
...
</location>
The reason you get an error for that is because in .NET, the custom app config section (such as the "location" section in your example) require you to provide a custom configuration section handler.
The main interface you need to use is IConfigurationSectionHandler
Here is an MSDN article on how to create your custom configuration handler.
I'd like to improve Neil's answer: Many say that modifying your web.config at runtime is not recommended. But here's the code how to do it.
This may be an ugly code, but for sure it'll work. - Jan Russel 'Rusty Programmer' Calachan
Not sure if this is exactly what you want but you can get sections within the web.config location element like so...
Does this help?
Taken from here
this is because
appSettings
is a known (default) config section in a .NET application. If you want to use your own config section, you have to create it.