asp.net - Query web.config for a key - in values -
can 1 let me know how bool result, verifying value exists in web.config's key.
scenario is,
i have tag in website...
<add key="isenabled" value="false"/>
website,
on key value keep site 'on' , 'off' using
public static bool isenabled = convert.toboolean(webconfigurationmanager.appsettings["isenabled "]); if(isenabled) { // }
now requirement got 3-4 websites now, want change above line like
<add key="sitesenabled" value="1,4,5"/>
because want enable 1st, 4th, 5th site
1 - static value 1st website, 2 - 2nd.....
but how do on , off...my websites like
public static bool onesiteenabled = convert.toboolean(webconfigurationmanager.appsettings[sitesenabled="1"]); // true public static bool twositeenabled = convert.toboolean(webconfigurationmanager.appsettings[sitesenabled="2"]); //false
please let me know ...thanks
i this:
using system.linq; var sitesenabled = configurationmanager.appsettings["sitesenabled"] != null ? configurationmanager.appsettings["sitesenabled"].split(',') : new string[0]; var onesiteenabled = sitesenabled.contains("1"); var twositeenabled = sitesenabled.contains("2");
Comments
Post a Comment