In the .NET API application for the .NET Core 2 web applications, I can redefine the urls configuration using appsettings.json , but in the appsettings.json papers they presented an additional file called βhosting.jsonβ, why? What is the point of adding complexity?
Below code fully works with appsettings.json :
public class Program { public static void Main(string[] args) { BuildWebHost(args).Run(); } public static IWebHost BuildWebHost(string[] args) { var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory())
The content of appsettings.json:
{ "Logging": { "IncludeScopes": false, "Debug": { "LogLevel": { "Default": "Warning" } }, "Console": { "LogLevel": { "Default": "Warning" } } }, "urls": "http://*:5005/" }
Side note: Commenting .SetBasePath(Directory.GetCurrentDirectory()) will support VS 2017 debugging mode (means apply launchSettings.json and automatically launch url), otherwise it will not happen. I believe this is due to the implementation of CreateDefaultBuilder .
source share