What's the point of hosting.json since appsettings.json is sufficient

前端 未结 1 446
小鲜肉
小鲜肉 2021-01-06 05:43

In .NET Core 2 Web API app, I could override configuration urls using appsettings.json, but in the official docs they introduced extra file \"hosti

相关标签:
1条回答
  • 2021-01-06 06:20

    I think, hosting.json is a configuration file used specifically for asp.net core application hosting. (if you know more about hosting)

    WebHostBuilder directly maps its keys with the hosting.json file and it doesn't have the capability to load the config section as we do in normal configuration settings.

    According to link attached in your post

    Use Configuration to configure the host. In the following example, host configuration is optionally specified in a hosting.json file. Any configuration loaded from the hosting.json file may be overridden by command-line arguments.

    If only we explicitly us hosting.json then the WebHostBuilder configurations can be modified using dotnet command.

    for example

    dotnet run --urls "http://*:8080"

    this will override the urls from hostings.json file.

    Hopefully, this may give some idea.

    PC: hosting.json can be renamed like myappsettings.json it can have configuration and Web Host Builder configuration.

    0 讨论(0)
提交回复
热议问题