Looping through web.config to get values

  • Thread starter Andy Sutorius via DotNetMonster.com
  • Start date
A

Andy Sutorius via DotNetMonster.com

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);
}
}
 
G

Guest

AppSettings is a simplified model and does not provide for multiple duplicate
key names.

You need to use a custom configuration section and associated handler.

Peter
 
A

Andy Sutorius via DotNetMonster.com

Thank you.
AppSettings is a simplified model and does not provide for multiple duplicate
key names.

You need to use a custom configuration section and associated handler.

Peter
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
[quoted text clipped - 10 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top