c# - How to Read Items into Arrays in web.config -
i'm trying build array of strings items in 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 string. public string _favourites = configurationmanager.appsettings ["favourite"];
i each favourite read string [ ] _favourites array semi-colon (i parse out later). web.config xml file can open 1 , pull data out, there easier way using configurationmanager?
i don't know if there hack it, have 1 setting multiple values;
<appsettings> <add key="favourite" value="url1;site1;url2;site2;url3;site3;" /> </appsettings>
or
<appsettings> <add key="favourite" value="url1=site1;url2=site2;url3=site3;" /> </appsettings>
another solution separate configuration file or store in database.
i imagine favourites change , changing web.config
has consequences - may cause app restart.
Comments
Post a Comment