title: ASP.NET 5: How to reload strongly typed configuration on change
body: <p>I have been able to set up strongly typed configuration in ASP.NET 5, and it works perfectly. I have also set the configuration to reload automatically when the <code>.json</code> configuration files are changed. But this only seems to work if I use the untyped configuration. The strongly typed configuration class still retains the old values when the <code>.json</code> files are changed.</p>
  
  <p>I'm setting up configuration like this:
  </p>
  
  <pre><code>public IConfiguration Configuration { get; set; }
  public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
  {
      // Setup configuration sources
      var builder = new ConfigurationBuilder()
          .AddJsonFile("config.json")
          .AddJsonFile($"config.{env.EnvironmentName}.json");
      Configuration = builder.Build()
          .ReloadOnChanged("config.json")
          .ReloadOnChanged($"config.{env.EnvironmentName}.json");
      /* ... (unrelated stuff edited away) ... */
  }
  </code></pre>
  
  <p>And binding it like this:</p>
  
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      /* ... (unrelated stuff edited away) ... */
      services.AddOptions();
      services.AddInstance(Configuration);
      services.Configure&lt;AppSettings&gt;(Configuration.GetSection("AppSettings"));
      services.Configure&lt;DbSettings&gt;(Configuration.GetSection("DbSettings"));
      /* ... (unrelated stuff edited away) ... */
  }
  </code></pre>
  
  <p>(The configuration files looks like this:)
  </p>
  
  <pre><code>{
      "AppSettings": {
          "This": "that",
          "Foo": "bar"
          /* etc... */
      },
      "DbSettings": {
          /* (db settings here) */
      }
  }
  </code></pre>
  
  <p>(And I correspondingly have a C# class like this:)
  </p>
  
  <pre><code>public class AppSettings
  {
      public string This { get; set; }
      public string Foo { get; set; }
      /* etc... */
  }
  </code></pre>
  
  <p>When I acquire the <code>IOptions&lt;AppSettings&gt;</code> via dependency injection, it doesn't change when I change the <code>config.json</code> and <code>config.Dev.json</code> files. I have to restart the entire web app to make the config class update. But if I instead use the untyped <code>IConfiguration</code> instance, it automatically changes when I change the json files.</p>
  
  <p>So the question is: How to make the strongly typed configuration change when I change the .json file, without having to restart the webapp?</p>