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>
fileattributeappSettingssection.configon a Configuration.Save call.configSourceattributeappSettingsconfigSourceon a Configuration.Save call.System.Configuration.ConfigurationErrorsExceptionis thrown if config source file does not exist.The
fileattribute 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
configSourceattribute contains the settings for the section which you declare the configSource for. For example, if you use theconfigSourceattribute of the pages section, then the external file will contain the settings for the pages section.http://www.codeproject.com/Messages/1463547/Re-difference-between-configSource-and-file-attrib.aspx