I\'m using asp.net + Autofac.
I\'m trying to load a custom JSON configuration file, and either create/instance an IConfiguration instance based on that, or at least
For .Net Core 2.2, you need to modify Program.cs:
Before
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup();
After
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
//This is how you attach additional JSON files
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.AddJsonFile("customSettings.json", optional: false, reloadOnChange: false);
})
//End of update
.UseStartup();
For the latest amendments and to add other kinds of custom settings, please refer to Microsoft documentation at the following article.