Saturday, March 31, 2012

Web Config File

Hi,

I wish to hold my global constant values in one location, my question is which is better for storage and retrieval? - Web Config File or in a Class?

Also can you please give me some slight detail on how to go about accessing the data in my web config file?

Regards

Hi,

In case you want to change the values without rebuilding the class, web.config is better. And second, web.config can easily be encrypted in case these globals are secrets.

Accessing data in web.config happens with classes in System.Configuration namespace (located in System.Configuration.dll assembly), and probably most frequently used is the ConfigurationManager class

Here's relevant links:http://msdn2.microsoft.com/en-us/library/system.configuration.configurationmanager.aspx (seemed not to work at the time I posted this, anyways it's link to the official docs)

http://www.dotnet-guide.com/configurationmanager-class.html


Check the below links

appSettings in Web.config
Web.Config Tutorial

HC


Just the info I required. Thanks!

0 comments:

Post a Comment