ASP.NET Core 2 – reading custom setting from appsettings.json core 2 released recently and I wanted to port my existing 1.1 app to 2.0. Updated the NuGet packages and most things remain same, but I noticed the reading app settings are broken (well there were few others too – maybe later.)

Imaging this is your appsettings.json file

Create AppSettings.cs and create properties that represent your app settings

Use it as below

remember to import the namespace using Microsoft.Extensions.Options;

Enjoy Core 2.0!!!

Leave a comment