How to get configurations variables?

I'm new to asp.net, been trying to create some apis. For now, I'm trying to get the db connection string, out of the appsettings.json. Is that possible or would I need to use something like .env variables with some extra configuration?
3 Replies
Head0nF1re
Head0nF1re2y ago
Did you try to search tho? But yes, you can get values from appsettings... https://learn.microsoft.com/en-us/ef/core/miscellaneous/connection-strings?source=recommendations#aspnet-core
Sun「無用」
Sun「無用」OP2y ago
yea, was seeing that, just didn't know where the Configuration class was thx Now I'm just having the good'ol migrations and db problem
Head0nF1re
Head0nF1re2y ago
IConfiguration is added automatically behind the scenes to the container (for Dependency Injection). It loads configurations/values from various sources, overriding previous values depending on what source has higher priority. You can read more about it here: - https://learn.microsoft.com/en-us/dotnet/core/extensions/configuration#concepts-and-abstractions
Want results from more Discord servers?
Add your server