ASP.NET web.config: configSource vs. file attributes

asp.netConfigurationWeb ConfigConfigsource

asp.net Problem Overview


Within an web.config-file in an ASP.NET-application some sections of config, like appSettings and connectionStrings, supports the attributes file and configSource.

What is the difference between using the file-attribute and the configSource-attribute? When should you use which attribute and can you use both?

<?xml version="1.0"?>
<configuration>
  <appSettings file="AppSettings.config">
  </appSettings>
  <connectionStrings configSource="ConnectionStrings.config">      
  </connectionStrings>
  <!-- ... -->
</configuration>

asp.net Solutions


Solution 1 - asp.net

file attribute

configSource attribute

The file attribute specifies an external file containing custom settings like you do in the appSettings entry of the web.config file. Meanwhile, the external file specified in the configSource attribute contains the settings for the section which you declare the configSource for. For example, if you use the configSource attribute of the pages section, then the external file will contain the settings for the pages section.

> The custom settings declared in the external config specified in the > file attribute will be merged with the settings in the appSettings > section in the web.config file. In the meanwhile, the configSource > does not support merging, it means that you'll have to move the entire > section settings into the external file.

http://www.codeproject.com/Messages/1463547/Re-difference-between-configSource-and-file-attrib.aspx

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSeb NilssonView Question on Stackoverflow
Solution 1 - asp.netMassimiliano PelusoView Answer on Stackoverflow