A Quick One: Pulling Items Out of the Web.config
Posted by: Paul Litwins Blog,
on 17 Aug 2006 |
View original | Bookmarked: 0 time(s)
Okay, this one is simple but frankly I always forget it because I don't use it that much AND because there are so many similar sounding classes, properties, and methods that it's not obvious.
To pull a connectionString out of the web.config by its name, use this syntax:
VB:Dim strCnx As String = ConfigurationManager.ConnectionStrings("connectionstring_name").ConnectionString
C#:string strCnx = ConfigurationManager.ConnectionStrings["connectionstring_name"].ConnectionString;
To pull an appSetting...