Looping through web.config to get values

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I have 2 values in the web.config with a key of ServersInCluster. However
when I execute this code I only get the 2nd value. I never get the 1st and
2nd value. Anyone know why?

private void Button2_Click(object sender, System.EventArgs e)
{
System.Collections.Specialized.NameValueCollection colNameVal;
colNameVal = System.Configuration.ConfigurationSettings.AppSettings;

foreach(string strKeysValue in colNameVal.GetValues("ServersInCluster"))
{
Response.Write(strKeysValue);
}
}

--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net/200601/1
.


Quantcast