JG Vimalan's Blog

It is all about coding!

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”];

Advertisements

November 28, 2009 - Posted by | ASP.NET

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: