ConfigurationManager.AppSettings物业 返回包含当前应用程序的默认配置的AppSettingsSection对象的内容的的NameValueCollection对象
但我需要AppSettingsSection对象,因为我需要去改变它configSource属性在运行时
解决方案 无功配置= WebConfigurationManager.OpenWebConfiguration(〜);
变种appSettingsSection =(AppSettingsSection)configuration.GetSection(的appSettings);
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");