To demonstrate retrieving the separated information, create a new webform named TestNewConfigurationFile. I could have used a longer name, but brevity is considered a virtue. Don’t bother to put any controls on it.
Enter the following code in the Page_Load method of your .aspx.cs file.
Listing 5 – The Web Form Code
private void Page_Load(object sender, System.EventArgs e)
string myNumber = Utility.GetCustomConfigValue("appReleaseSection", "ReleaseNumber");
string myDate = Utility.GetCustomConfigValue("appReleaseSection", "ReleaseDate");
Response.Write("Release: " + myNumber + "<br />Date: " + myDate);
Build and run!
Bing, Bam, Boom – we be done!