Can I set listen URLs in appsettings.json in ASP.net Core 2.0 Preview?
To set listen URLs in appsettings.json, add "Kestrel" section:
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://localhost:5000"
}
}
}
Reference: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-2.2
I got it working with this
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseConfiguration(new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hosting.json", optional: true)
.Build()
)
.UseStartup<Startup>()
.Build();
And the hosting.json
{ "urls": "http://*:5005;" }