I\'m trying to use ConfigurationManager.AppSettings.GetValues() to retrieve multiple configuration values for a single key, but I\'m always receiving an array o
Here is full solution: code in aspx.cs
namespace HelloWorld
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
UrlRetrieverSection UrlAddresses = (UrlRetrieverSection)ConfigurationManager.GetSection("urlAddresses");
}
}
public class UrlRetrieverSection : ConfigurationSection
{
[ConfigurationProperty("", IsDefaultCollection = true,IsRequired =true)]
public UrlCollection UrlAddresses
{
get
{
return (UrlCollection)this[""];
}
set
{
this[""] = value;
}
}
}
public class UrlCollection : ConfigurationElementCollection
{
protected override ConfigurationElement CreateNewElement()
{
return new UrlElement();
}
protected override object GetElementKey(ConfigurationElement element)
{
return ((UrlElement)element).Name;
}
}
public class UrlElement : ConfigurationElement
{
[ConfigurationProperty("name", IsRequired = true, IsKey = true)]
public string Name
{
get
{
return (string)this["name"];
}
set
{
this["name"] = value;
}
}
[ConfigurationProperty("url", IsRequired = true)]
public string Url
{
get
{
return (string)this["url"];
}
set
{
this["url"] = value;
}
}
}
}
And in web config