I was struggling to use custom urls
for Kestrel
and I finally found a combination of settings and builders that work but I'm really confused why does the following work:
var configuration =
new ConfigurationBuilder()
.AddJsonFile("hosting.json", optional: true, reloadOnChange: true)
.Build();
var host =
WebHost.CreateDefaultBuilder(args)
.UseContentRoot(contentRootPath)
.UseConfiguration(configuration)
.UseStartup<Startup>()
.Build();
but not this:
var host =
WebHost.CreateDefaultBuilder(args)
.UseContentRoot(contentRootPath)
.ConfigureAppConfiguration((context, builder) =>
{
builder.AddJsonFile("hosting.json", optional: true, reloadOnChange: true);
})
.UseStartup<Startup>()
.Build();
It just ignores the hosting.json
file as if it wasn't there.
What is the difference between using your own builder vs. using the ConfigureAppConfiguration
extension? Is there a rule of thumb when to use which?