On an Asp.Net Core 3.1 application I have the following section on AppSettings:
"Logins": [
{
"Name": "Facebook",
"Id": "fb_id",
"Secret": "fb_secret"
},
{
"Name": "Google",
"Id": "go_id",
"Secret": "go_secret"
}
]
I am trying to get values, such as Id of Facebook, so I tried:
Configuration.GetValue<String>("Logins:Facebook:Id")
But this won't work ... How can I get the values?
LoginsandFacebookare sections. Instead of reading strings, why not read the entireFacebookobject though? Or read the entire array at once? You could use egGetorBindto load strongly-typed objects on startup, register with DI and inject them as neededConfigurrattion.GetSection("Logins").Get<MyLogin[]>()to load the entire array