2

For the moment almost all blog posts covering configuration with the new ASP.NET 5 and MVC 6 using json for config is using something like this:

var token = configuration.Get<string>("AppData:CompanyName");

For example this question: How to read AppSettings values from Config.json in ASP.NET Core

But since 6 august this function is removed (if you're using bleeding edge releases) with almost no information on what to use instead.

For me this first occurred when switching to from beta5 to beta6 of Microsoft.Framework.Configuration.Json.

Community
  • 1
  • 1
Jonas Stensved
  • 14,378
  • 5
  • 51
  • 80

1 Answers1

1

tl;dr;

Do it like this to get it working:

var companyName = Configuration["AppData:CompanyName"];
var branchName = Configuration["AppData:BranchName"];
// etc.

Explanation and source:

This commit removed the Get function: https://github.com/aspnet/Configuration/commit/ddd7c42ece30f0b7bb57a91ae7a627f2f99b9cf2

Some further comments when digging in the issue can be found here: https://github.com/aspnet/Configuration/issues/246

Jonas Stensved
  • 14,378
  • 5
  • 51
  • 80