How to obtain the OnChange event triggered after appsettings.json manually modifies and saves in asp.net core?

encountered a requirement. After modifying the appsettings.json file, you need to trigger a cascading event with modified settings. Does anyone know how to get this OnChange event?

configure the appsettings.json code as follows:

new ConfigurationBuilder()
        .SetBasePath(environment.ContentRootPath)
        .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
Jun.09,2021

looked at the source code of Microsoft.Extensions.Configuration .
found that JsonConfigurationProvider 's base class ConfigurationProvider has a protected void OnReload () , so the solution is clear.
inherits JsonConfigurationProvider to create a new Provider , and then override OnReload method.

then in Program.cs

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
        .ConfigureAppConfiguration((builderContext, config) =>
         {     
            IHostingEnvironment env = builderContext.HostingEnvironment;
             var c = config as Microsoft.Extensions.Configuration.ConfigurationBuilder;
            //c.Sourcesappsettings.json  JsonConfigurationProvider
            //c.SourcesProviderc.SourcesList
         })
         .UseStartup<Startup>();
Menu