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?
In my web.config, appSettings section, I have several keys. What is the preferred way
Share
I found that
ConfigurationManager.AppSettings["key"](requiresSystem.Configurationassembly reference) will returnnullif the key is not found.In that case, I
throwan instance of my ownMyAppConfigurationExceptionwith something helpful: like Couldn’t open repository, configuration key RepositoryAccess.Customer was not found.Hope that helps!