【问题标题】:Blazor WASM wwwroot/appsettings.json not present in template模板中不存在 Blazor WASM wwwroot/appsettings.json
【发布时间】:2020-12-30 02:09:15
【问题描述】:
根据this 文章 Blazor WASM 默认从 wwwroot/appsettings.json 和 wwwroot/appsettings.{environment}.json 加载配置。但是,当我生成 Blazor WASM 应用程序时,wwwroot 下没有此类文件。我的 dotnet 版本是 5.0.101,我在 Ubuntu 20.04 上,我的目标框架是 net5.0 。当我创建由 ASP.NET 核心托管的模板时,我确实在服务器项目中看到了具有此类名称的文件。这是它实际上指的是什么,还是我错过了其他东西?
【问题讨论】:
标签:
c#
asp.net-core
blazor-webassembly
【解决方案1】:
好的,我知道发生了什么。我误读了文档;如果您将-au Individual 标志指向 不 由 asp.net 核心托管的 blazor wasm 应用程序,则 wwwroot 下有 appsettings.json 文件。
【解决方案2】:
是的。如果您需要模板,这里有一个基本模板:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"MyDatabase": "Server=???;Initial Catalog=???;User ID=???;Password=???",
},
"ApiSettings": {
"SomeApiValue": "Some API value"
}
}