I'm trying to build an array of strings from items in a web.config file (in IIS).
web.config
<appSettings>
<add key="favourite" value="url1; site1" />
<add key="favourite" value="url2; site2" />
<add key="favourite" value="url3; site3" />
</appSettings>
C#
// Reads first favourite into string.
public string _favourites = ConfigurationManager.AppSettings ["favourite"];
I would like each favourite to be read into string [ ] _favourites array with the semi-colon (I would parse that out later). web.config is an XML file so I can open it as one and pull the data out, but is there an easier way to do this using ConfigurationManager?
ConfigurationManager.Appsettingswill only return you the last value for the key. I found a workaround here, but I haven't tested it. codeproject.com/Articles/4302/…