views:

32

answers:

4

in one of the application i have been reffering connection string is stored in appsettings! till now i have been storeing the connection in <connectionstring/> element. But, what is the correct way?

So my quetion is, What is the differences between <connectionstring> and <appsettings> in web.config, are there any specific reason why i should or should not be storing connection string in appsettings? Are there any rules / guidlines provided to follow? Or is this completely the choice of the developer?

A: 

Connection strings are generally kept in the <connectionstring/> element...and is a good guideline since it's named properly.

Sometimes you might use a third party control or usercontrol that looks for the connection string in a key in the <appsettings> element. That should be the only exception to the guideline.

Ed B
+1  A: 

This article might be helpful

http://peterkellner.net/2008/02/23/webconfigbestpractice/

VoodooChild
+1  A: 

As far as I know it doesn't make a huge amount of difference, other than it being in the "correct" place - the main advantage of putting connection strings in their own section (you do encrypt your connection strings.. right?) is so you can encrypt that section without encrypting all of the settings you might want to change.

Steven Robbins
Also, your server guys can encrypt and modify the connection string section separately, so as you move from dev to qa to production getting that right is their responsibility, not yours.
Joel Coehoorn
A: 

Additionally, in IIS7, connect strings can be maintained through the respective IIS7 Administration.

flq