ConfigurationManager.AppSettings Property Returns a NameValueCollection object that contains the contents of the AppSettingsSection object for the current application's default configuration.
but I need AppSettingsSection object because I need to change it configSource property in runtime
var configuration = WebConfigurationManager.OpenWebConfiguration("~");
var appSettingsSection = (AppSettingsSection)configuration.GetSection("appSettings");
You can get the AppSettingsSection
with the Configuration.GetSection method or with the Configuration.AppSetting property.
To get an Configuration
object you need to use the ConfigurationManager.Open...
or the WebConfigurationManager.Open...
methods:
string sectionName = "appSettings";
var config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
AppSettingsSection appSettingSection =
(AppSettingsSection)config .GetSection(sectionName);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With