Tuesday, March 11, 2008

Store application information in web.config

To store application information in web.config is easy:

In Web.config

<appsettings>
<add value="xxx@xxx.com" key="adminEmail">
</appsettings>

In the program, this is how you retrieve the information:

string sEmail = System.Web.Configuration.WebConfigurationManager.AppSettings["adminEmail"].ToString();

Storing this type of info in the web.config allow you to set it at anytime without recompiling your program. So when you are testing, set it to your own email address so you will set the email. I am tired of getting and deleting the testing emails :)

No comments: