Friday, October 5, 2007

How to store and retrieve settings in web.config file for VS 2005

Add appSettings tag inside configuration tag in your web.config file, as follows:


<configuration>
<appSettings>
<add key="MyKey" value="MyValue" />
</appSettings>
</configuration>

Here is one of the ways you can retrieve the values in your code:

string MyValue = System.Configuration.ConfigurationManager.AppSettings.Get("MyKey");

No comments: