JG Vimalan's Blog

Sharing is caring :)

Use multiple web.config

In ASP.Net application, if you want to separate the database connection string from Web.config file, then you can place it in another Web.DB.Config file and can refer it from Web.config file as shown below,

<appSettings file=”Web.DB.Config”>

This Web.DB.Config willl have the actual connection string as shown below,

<appSettings>
 <add key=”DBConn” value=” <your db connection string here>”/>

The DB Connection string can be accessed as shown below,

ConfigurationSettings.AppSettings[“DBConn”];

November 28, 2009 Posted by | ASP.NET | Leave a comment