In two projects (.NET Core Web API and .NET Core WindowsService) I use appsettings.json for configuration.
var configuration = new ConfigurationBuilder() .SetBasePath(System.IO.Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddEnvironmentVariables() .Build();
In both cases, I set reloadOnChange to true and use it as the injected IOptions through dependency injection. Inside the web api in the controller classes and inside the service into classes that use settings.
Unfortunately, I feel that the values ββdo not change when appsettings.json changes.
In the web api, I created a controller to simply return the string value from config, and this will remain the same as when I started it.
So my questions are:
- Does anyone know if this should work out of the box (at least in the web api)?
- Anything I have to do for it to work?
source share