Skip to main content


Showing posts from October, 2016

ASP.NET Core environment aware strongly typed configuration in MongoDB

This is targetted to save in MongoDB but the technique can be used in any targetted backend with key value setting based on IConfigurationProvider Data property.

Basically, the provided interface works based Data property having a type as IDictionary<string, string>. So, whatever class we create it has to be serialized based on same. We would simplify this by creating an abstract class to have certain serialization logic.

This is sample setting for the application. If you check the structure,  Setting is the main class and nested items are Azure, Message, Email, Twilio. The key value needs to be composed based on parent and child classes separated by colons.

Just like above, we need to populate settings from our different setting classes.

Implementation can be grouped in these sections.
- Application level configuration classes.
- Registration of configuration on ASP.NET Core.
- Environment level configuration, this would little mixed with above.
Application level configuration…