appsettings.json (both dev and prod) ignored by ASP.NET Core 2.0? appsettings.json (both dev and prod) ignored by ASP.NET Core 2.0? json json

appsettings.json (both dev and prod) ignored by ASP.NET Core 2.0?


Looks like you need to call UseConfiguration directly to set an URL address read from appsettings.json:

public static IWebHost BuildWebHost(string[] args){        var config = new ConfigurationBuilder()            .AddJsonFile($"appsettings.Development.json", optional: true)            .Build();        return WebHost.CreateDefaultBuilder(args)            .UseConfiguration(config)            .UseStartup<Startup>()            .Build();}

CreateDefaultBuilder method implementation uses ConfigureAppConfiguration method internally, not UseConfiguration. And there is a difference (from related Github issue):

The ConfigureAppConfiguration was intended to configure the IConfiguration in the application services whereas UseConfiguration is intended to configure the settings of the WebHostBuilder. Since the url address is a setting on the WebHostBuilder only UseConfiguration will work here.

Note that the WebHostBuilder's configuration is added to the application's configuration but the converse is not true; configuring the application's configuration does not affect the WebHostBuilder's configuration.


Instread of "Kestel.Endpoints" section your appsetting.json should simply have the following:

{   ...   "urls": "http://127.0.0.1:5001"}