关于在web.config中保存设置的两种方式,我有一些问题.
Appsettings:
<appSettings>
<add key="key1" value="value1"/>
<add key="key2" value="value2"/>
</appSettings>
Usage in code-behind:
ConfigurationManager.AppSettings["key1"];
ApplicationSettings/ Properties (autogenerated by using the 'properties'-tab in the project)
Look in web.config
<applicationSettings>
<Projectname.Properties.Settings>
<setting name="TestEnvironment" serializeAs="String">
<value>True</value>
</setting>
</Projectname.Properties.Settings>
</applicationSettings>
Usage in code-behind:
Properties.Settings.Default.TestEnvironment
那么,web.config中设置的这两种存储可能性有什么不同呢?
据我所知,appSettings的一个缺点是您自己修改了web.config,并且appSettings不是强类型的,其中是应用程序设置.
两者都可以在Web部署项目中替换.
就我而言,有no use for appSettings个.我错过什么了吗?哪个是历史上最古老的?