Asp.net 是否将appSettings拆分为多个节/文件?
我是否可以将appSettings拆分为多个外部配置文件,并将它们包含在main web.config中 以下是我尝试过的,但不起作用:( 在web.config中,我定义了一个新的部分:Asp.net 是否将appSettings拆分为多个节/文件?,asp.net,web-config,configsection,Asp.net,Web Config,Configsection,我是否可以将appSettings拆分为多个外部配置文件,并将它们包含在main web.config中 以下是我尝试过的,但不起作用:( 在web.config中,我定义了一个新的部分: <configSections> <section name="ssoConfiguration" type="System.Configuration.NameValueSectionHandler"/> </configSections> 以下是我的这一部
<configSections>
<section name="ssoConfiguration" type="System.Configuration.NameValueSectionHandler"/>
</configSections>
以下是我的这一部分:
<ssoConfiguration>
<add key="SSOEnabled" value="true"/>
</ssoConfiguration>
当我调用System.Configuration.ConfigurationManager.AppSettings[“SSOAbled”]时,它返回null
你知道为什么吗
此外,我将有多个包含此类appsettin的部分-是否可以在多个外部配置文件中定义它们,并将它们包含在main web.config中
谢谢。因为您正在访问AppSettings,但“SSOEnabled”设置位于另一部分(“ssoConfiguration”)。请重试
var ssoConfiguration = (NameValueCollection)ConfigurationManager.GetSection("ssoConfiguration")
var ssoEnabled = ssoConfiguration["SSOEnabled"];