Summary
.NET Core added many features, such as configuration and logging, that are now part of .NET 5. The new APIs are better and provide a lot of value compared to the old .NET Framework ones. Most of the boilerplate code is gone, and almost everything is on an opt-in basis.
Options allow us to load and compose configurations from multiple sources while using those easily in our systems through simple C# objects. It removes the hassle of the previous configuration from web.config
and makes it easy to use. No more complex boilerplate code is needed to create custom web.config
sections; just add a JSON object to appsettings.json
, tell the system what section to load, what the type should be, and voilà – you have your strongly-typed options! The same simplicity applies to consuming settings: inject the desired interface or the class itself and use it. With that, you are up and running; no more static ConfigurationManager
or other structures that are hard to test.