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 webservertalk.com
http://www.webservertalk.com/Uwe/Fo...sp-net/200601/1AppSettings is a simplified model and does not provide for multiple duplicat
e
key names.
You need to use a custom configuration section and associated handler.
Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"Andy Sutorius via webservertalk.com" wrote:
> 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 webservertalk.com
> http://www.webservertalk.com/Uwe/Fo...sp-net/200601/1
>
Thank you.
Peter Bromberg [C# MVP] wrote:
>AppSettings is a simplified model and does not provide for multiple duplica
te
>key names.
>You need to use a custom configuration section and associated handler.
>Peter
>
>[quoted text clipped - 10 lines]
Message posted via webservertalk.com
http://www.webservertalk.com/Uwe/Fo...sp-net/200601/1
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment