How can I read properties from appsettings.json (appsettings.production.json) inside x.Application project services? I need access to connection string beside other variables. I am using dotnet core api + angular solution
3 Answer(s)
-
0
You can inject IConfigurationRoot to read appsetting.json
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-2.2
-
1
ideally, you should consider using
https://aspnetboilerplate.com/Pages/Documents/Startup-Configuration#creating-configuration-for-a-module
as you won't want every single of your API calls to read from
appsettings.json
-
0
You can inject IConfigurationRoot to read appsetting.json
That was not giving me the full config. But, I injected
IWebHostEnvironment env
and then calledenv.GetAppConfiguration()
which gave me aIConfigurationRoot
that did have all the config.