The Problem: You changed a value in appsettings.json, but the app keeps using the old value until you restart the server.
The Fix: Inject IOptionsSnapshot<T> instead of IOptions<T>. It reads the config file every time the request is made.
public class MyService
{
private readonly MySettings _settings;
// Updates immediately when json changes!
public MyService(IOptionsSnapshot<MySettings> options)
{
_settings = options.Value;
}
}
