I have got some configuration added in my appsettings.json file of my asp.net core 3.0 web api project and the file looks something like this:
{
"Logging":{..},
"AllowedHosts": "*",
"Section1": {
"Key1": "Value1",
"Key2": "Value2",
....
}
}
I want to iterate through all the keys in this particular section, Section1 and perform some action on them. I tried the following but it doesn't work:
foreach (var key in ConfigurationManager.AppSettings.AllKeys)
{
var key = ConfigurationManager.AppSettings["Key1"];
// perform some action
}
ConfigurationManager.AppSettings doesn't contain anything as can be seen in the screenshot below:

What else do I need to do to make this work?
I have tried var v = this._configuration.GetSection("Section1").GetSection("Key1");where _configuration is of the type IConfiguration and it works as expected. But again, like I mentioned I don't want this, instead I want to iterate through all the list of keys in the appsettings and perform some action on them.
Any help would be great.