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?
Logins
andFacebook
are sections. Instead of reading strings, why not read the entireFacebook
object though? Or read the entire array at once? You could use egGet
orBind
to load strongly-typed objects on startup, register with DI and inject them as needed β Panagiotis KanavosConfigurrattion.GetSection("Logins").Get<MyLogin[]>()
to load the entire array β Panagiotis Kanavos