title: How can I add a custom JSON file into IConfiguration?
body: <p>I'm using asp.net + Autofac.</p>
  
  <p>I'm trying to load a custom JSON configuration file, and either create/instance an IConfiguration instance based on that, or at least include my file into whatever IConfiguration asp.net builds by default.</p>
  
  <p>My problem is that asp.net seems to override the dependency registration for IConfiguration.</p>
  
  <p>I can't seem to register my own IConfiguration object - the DI container will always resolve this to some instance that seems to have been generated by the asp.net library itself.</p>
  
  <p>And I'm not sure how I can get asp.net to at least load my custom config file additionally - i.e. if there is any way to get a hold of the ConfigurationBuilder it uses, and add my own file before it is building the IConfiguration object.</p>
  
  <p>I've tried the following:</p>
  
  <pre><code>public class Startup
  {
      public IConfigurationRoot Configuration { get; }
  
      public Startup(IHostingEnvironment env)
      {
          this.Configuration = new ConfigurationBuilder()
              .SetBasePath(path)
              .AddJsonFile("somefile.json")
              .Build();
      }
  
      public IServiceProvider ConfigureServices(IServiceCollection services)
      {
          // Add framework services.
          services
            .AddMvc()
            .AddControllersAsServices();
  
           var builder = new ContainerBuilder();
           builder.Register(x =&gt; this.Configuration).As&lt;IConfiguration&gt;();
           builder.Populate(services);
  
           var container = builder.Build();
  
           // This will return another IConfiguration instance then the one I registered; 
           // namely One that contains 1 provider, a MemoryConfigurationProvider
           var xxx = container.Resolve&lt;IConfiguration&gt;();
  
           return new AutofacServiceProvider(container);
      }
  }
  </code></pre>
  
  <p>How can I get asp.net to load my custom JSON config file as well?</p>