In my web.config, appSettings section, I have several keys. What is the preferred way to handle in code any keys that are missing? For example, a key name is changed due to a typo. I know I can use various methods to test if the values of said keys exist but what about the key itself?
views:
24answers:
1
A:
I found that ConfigurationManager.AppSettings["key"]
(requires System.Configuration
assembly reference) will return null
if the key is not found.
In that case, I throw
an instance of my own MyAppConfigurationException
with something helpful: like Couldn't open repository, configuration key RepositoryAccess.Customer was not found.
Hope that helps!
Kieren Johnstone
2010-07-15 19:36:33