MVC 读取 Web.Config

<connectionStrings> 
<add name="A" connectionString="A"/>
<add name="B" connectionString="B"/>
<add name="C" connectionString="C"/>
<add name="D" connectionString="D"/>
<add name="E" connectionString="e"/>
<add name="F" connectionString="f"/>
<add name="G" connectionString="g" />
</connectionStrings>

 

web.config 中有这么一组数据,请问在代码中怎么循环获取


陪伴而非守候
浏览 333回答 1
1回答

UYOU

通过对 ConfigurationManager.ConnectionStrings 进行 foreach 操作得到 ConnectionStringSettingsforeach(ConnectionStringSettings&nbsp;css&nbsp;in&nbsp;ConfigurationManager.ConnectionStrings) {&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;connectionString&nbsp;=&nbsp;css.ConnectionString; }
打开App,查看更多内容
随时随地看视频慕课网APP