Blazor WASM wwwroot/appsettings.json 不存在于模板中
Blazor WASM wwwroot/appsettings.json not present in template
根据 this 文章,Blazor WASM 默认从 wwwroot/appsettings.json 和 wwwroot/appsettings.{environment}.json 加载配置。但是,当我生成 Blazor WASM 应用程序时,wwwroot 下没有这样的文件。我的 dotnet 版本是 5.0.101,我在 Ubuntu 20.04,我的目标框架是 net5.0 。当我创建由 ASP.NET 核心托管的模板时,我确实在服务器项目中看到了具有此类名称的文件。这是它实际指的是什么,还是我遗漏了什么?
好的,我知道发生了什么。我误读了文档;如果你有一个 blazor wasm 应用程序的 -au Individual
标志,则 wwwroot 下有 appsettings.json 个文件,该应用程序 不是 由 asp.net 核心托管。
是的。如果您需要模板,这里有一个基本模板:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"MyDatabase": "Server=???;Initial Catalog=???;User ID=???;Password=???",
},
"ApiSettings": {
"SomeApiValue": "Some API value"
}
}
根据 this 文章,Blazor WASM 默认从 wwwroot/appsettings.json 和 wwwroot/appsettings.{environment}.json 加载配置。但是,当我生成 Blazor WASM 应用程序时,wwwroot 下没有这样的文件。我的 dotnet 版本是 5.0.101,我在 Ubuntu 20.04,我的目标框架是 net5.0 。当我创建由 ASP.NET 核心托管的模板时,我确实在服务器项目中看到了具有此类名称的文件。这是它实际指的是什么,还是我遗漏了什么?
好的,我知道发生了什么。我误读了文档;如果你有一个 blazor wasm 应用程序的 -au Individual
标志,则 wwwroot 下有 appsettings.json 个文件,该应用程序 不是 由 asp.net 核心托管。
是的。如果您需要模板,这里有一个基本模板:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"MyDatabase": "Server=???;Initial Catalog=???;User ID=???;Password=???",
},
"ApiSettings": {
"SomeApiValue": "Some API value"
}
}