So you like the idea of storing variables centrally, and want to know how to implement that in your c# web site.

Simply add the following node to your web.config if it does not already exist

[codesyntax lang=”xml”]

<configuration>
  <appSettings>
    <add key="brad" value="this came from web.config"/>
  </appSettings>
</configuration>

[/codesyntax]

Then import the Configuration namespace at the top of your codebehind with

[codesyntax lang=”csharp”]

using System.Web.Configuration;

[/codesyntax]

Finally in your webform or codebehind file to retrieve the stored value from the key/value pair stored in web.config simply use this statement

[codesyntax lang=”csharp”]

yourVariable = WebConfigurationManager.AppSettings["Brad"];

[/codesyntax]