Use configSource attribute to manage Web.Config sections in ASP.Net 2.0
Different Sections in Web.Config can be managed by using external XML files, like Connection strings, Appsettings .....
Create a XML file with the respective settings and put that file in App_Data folder to protect
<?xml version="1.0" standalone="yes"?>
<connectionstrings>
<!-- Connection String for SQL Server 2005 Express -->
<add name="SiteSqlServer" connectionstring="Your Connection" providername="System.Data.SqlClient" />
<!-- Connection String for SQL Server 2000/2005
<add name="SiteSqlServer" connectionstring="Your Connection" providername="System.Data.SqlClient" /> -->
</connectionstrings>
Save the file in App_Data folder you need to change the Settings in Web.Config
<connectionstrings configsource="App_Data\yourFileName.xml" />
You can manipulate the values by simply changing the respective XML files. No need to change the Web.Config any more.
Create a XML file with the respective settings and put that file in App_Data folder to protect
<?xml version="1.0" standalone="yes"?>
<connectionstrings>
<!-- Connection String for SQL Server 2005 Express -->
<add name="SiteSqlServer" connectionstring="Your Connection" providername="System.Data.SqlClient" />
<!-- Connection String for SQL Server 2000/2005
<add name="SiteSqlServer" connectionstring="Your Connection" providername="System.Data.SqlClient" /> -->
</connectionstrings>
Save the file in App_Data folder you need to change the Settings in Web.Config
<connectionstrings configsource="App_Data\yourFileName.xml" />
You can manipulate the values by simply changing the respective XML files. No need to change the Web.Config any more.
Comments