Click here to Skip to main content
15,887,911 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am adding a Custom configuration provider in ConfigureWebHostDefaults and application configuration from Database.

What I have tried:

C#
Host.CreateDefaultBuilder(args)               
                    .ConfigureWebHostDefaults(webBuilder =>
                    {
                        webBuilder.ConfigureAppConfiguration(AddDbConfiguration);
                        webBuilder.UseStartup<Startup>();
                    })


then add in IServiceCollection

C#
services.Configure<List<SysAppConfig>>(Configuration.GetSection("AppConfig"));


but when I checking values in Configure method

C#
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IOptionsMonitor<List<DTO_SysAppConfig>> optionsAccessor)
        {

            var option1 = optionsAccessor.CurrentValue.Count;

.......
}


Its showing count=0 .

please suggest me how to get values from Custom configuration provider and add in option for further use.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900