Wednesday, November 28, 2007

Variables in web.config

Web.config

< ?xml version="1.0"?>
...
< appSettings>
< add key="SiteUrl" value="http://dev.site.com/sales"/ >
< add key="ListName" value="Shared Documents"/ >
< /appSettings> 
...
< /system.web >
< /configuration >

Some.aspx.cs

using System.Configuration;

string siteUrl = ConfigurationManager.AppSettings["SiteUrl"];
string listName = ConfigurationManager.AppSettings["ListName"];

No comments: