相关疑难解决方法(0)

ASP.NET web.config:configSource与文件属性

web.configASP.NET应用程序的-file中,配置的某些部分(如appSettingsconnectionStrings)支持属性fileconfigSource.

使用file-attribute和configSource-attribute有什么区别?什么时候应该使用哪个属性,你可以同时使用它们吗?

<?xml version="1.0"?>
<configuration>
  <appSettings file="AppSettings.config">
  </appSettings>
  <connectionStrings configSource="ConnectionStrings.config">      
  </connectionStrings>
  <!-- ... -->
</configuration>
Run Code Online (Sandbox Code Playgroud)

asp.net configuration web-config configsource

179
推荐指数
1
解决办法
5万
查看次数

appsettings文件属性是否覆盖了app.config中的内容?

app.config中的appsettings标记具有文件属性:

<appSettings file="other.config">
..
..
</appSettings>
Run Code Online (Sandbox Code Playgroud)

这是如何运作的?它会将appSettings(原始)中的内容与other.config文件合并吗?或者它会覆盖它吗?如果other.config文件不存在,该怎么办呢?

我自己尝试,如果一个键不在原来的,它似乎没有从other.config读取它?

other.config文件应该只有xml节点,还是应该都在appsettings元素中?

<appSettings>
  <userId>123</userId>
</appSettings>
Run Code Online (Sandbox Code Playgroud)

要么

<userId>123</userId>
Run Code Online (Sandbox Code Playgroud)

c# asp.net web-config visual-studio

22
推荐指数
2
解决办法
1万
查看次数