Friday, January 19, 2007 2:40 AM
dbottjer
ASP.NET Connection Strings Configuration
ASP.NET 2.0 introduced a new connection strings section to the web.config. All connection strings can be centralized in this one section making tasks like connection string encryption easier. Dave Strommer recently showed me how to remove the connection strings from the web.config and place the entire connection string section in another config file. This connections.config is then referenced from within the web.config. This is a nice technique when maintaining several applications that connect to the same databases. A connections.config file can be versioned and then referenced by the application as basically a library or include. See the code below as an example.
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings configSource="appSettings.config"/>
<connectionStrings configSource="connections.config"/>
<system.web>
<compilation debug="true" />
<authentication mode="Windows"/>
<identity impersonate="true"/>
</system.web>
</configuration>
Filed under: ASP.NET