C#C
C#3y ago
Trenyc

Properties of IConfigurationSection.Get are null?

I have a very simple test case set up using Microsoft.Extensions.Configuration and Microsoft.Extensions.Configuration.Binder. The config (aopsettings.json):

{
  "Foo": "bar"
}

And the class:

public class Configuration
{
    public string Foo;
}

The configuration builds correctly. I can see it contains the Foo property when debugging. However, when I try to use var test = _configuration.Get<Configuration>(), the Foo property of test is null.

I'm confused what is going wrong here. Can anyone spot the mistake?
Was this page helpful?