本文介绍了如何获得的web.config的appSettings的配置节没有的NameValueCollection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ConfigurationManager.AppSettings物业返回包含当前应用程序的默认配置的AppSettingsSection对象的内容的的NameValueCollection对象
但我需要AppSettingsSection对象,因为我需要去改变它configSource属性在运行时
解决方案
无功配置= WebConfigurationManager.OpenWebConfiguration(〜);
变种appSettingsSection =(AppSettingsSection)configuration.GetSection(的appSettings);
ConfigurationManager.AppSettings PropertyReturns 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");
这篇关于如何获得的web.config的appSettings的配置节没有的NameValueCollection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!