Configuration.GetSection always returns null

前端 未结 9 1073
借酒劲吻你
借酒劲吻你 2020-12-16 09:01

Every time I call Configuration.GetSection, the Value property of the returned object is always null.

My Startup constructor

相关标签:
9条回答
  • 2020-12-16 09:47
    var serviceProvider = services.BuildServiceProvider();
    

    must come after all services.Configure calls.

    0 讨论(0)
  • 2020-12-16 09:51

    In my case for Web Api Core 2.1, I needed Program.cs in the project root folder (the same folder as Startup.cs).

    0 讨论(0)
  • 2020-12-16 09:54

    If all the other answers do not fix the problem, another reason could be that the properties of the Options class are private (or do not have accessible setters).

    0 讨论(0)
提交回复
热议问题