Warning: This post is over 11 years old and may no longer be accurate, especially in regards to more updated technology currently available. Additionally, links in this post may be broken. Please keep this in mind while reading.
Today I've just released version 1.1 of ContextConfig. The main update is support for overriding ConfigurationManager.AppSettings["key"] to check the ContextConfig file before defaulting to the web.config value. What this means is that, if enabled (It can be disabled easily, if you don't want the functionality), you don't need to use the ContextConfig.GetValue("key") syntax in your code. It also means that any current existing code which looks for appkeys will automatically support ContextConfig.
When enabled, any calls to ConfigurationManager.AppSettings["key"] will utilize ContextConfig data as follows:
- If there is a value specified for the key for the current environment, it will be used.
- If there is no matching value for this environment, but there is a default value, the specified default value will be used.
- If there is no record of the key in the ContextConfig.config file, it will use the value specified in the web.config <appSettings> section.
- If there is no matching key in the web.config, an empty string will be returned, as usual.
To enable “Override Configuration Manager” mode, a call needs to be made at application start to “ContextConfigOverride.ActivateOverride().” An HttpModule class has been included, so the call can be made in a web application by simply registering the HttpModule in the application’s web.config and setting the ContextConfig.config “OverrideConfigurationManager” attribute to "true". Alternatively, a call in the Global.asax “Application_Start()” section can be used.
Check out the documentation for all the details.
Get the updated Umbraco Package or the Source Code to use in any ASP.Net web project.
Watch the version 1.0 Demo video.
PS. Please Vote on possible new features