Configuration.GetSection always returns null

前端 未结 9 1218
借酒劲吻你
借酒劲吻你 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:36

    Just modify your ConfigureServices method to be like following:

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddOptions();
    
        services.Configure(Configuration.GetSection("SqliteSettings"));
    
        services.AddMvc();
    }
    

    and it should work.

提交回复
热议问题