How to check if an appSettings key exists?
if (ConfigurationManager.AppSettings.Settings.AllKeys.Contains("myKey"))
{
// Key exists
}
else
{
// Key doesn't exist
}
MSDN: Configuration Manager.AppSettings
if (ConfigurationManager.AppSettings[name] != null)
{
// Now do your magic..
}
or
string s = ConfigurationManager.AppSettings["myKey"];
if (!String.IsNullOrEmpty(s))
{
// Key exists
}
else
{
// Key doesn't exist
}