“发生了未处理的错误。”在 Blazor 应用程序中使用标识脚手架元素时

“An unhandled error has occurred.” when using Identity scaffold elements in a Blazor application

  1. 创建了一个 Blazor WebAssembly 3.2.0 预览版 3 使用 Individual User Accounts[=32] 的应用程序模板=] 核心托管 参数
  2. 此时,一切正常启动并显示标准 Blazor 应用程序。
  3. 添加了脚手架注册登录页面
  4. 应用程序正常启动,但显示模板停止工作并出现一条消息“发生未处理的错误”

由此github issue

The Identity scaffolder adds a wwwroot folder to the Server project with the default set of styles and other assets for the default Identity UI. These styles then override the styles that come from the Client project. In particular, both the Client and Server projects end up with a css/site.css.

您有以下两种选择:

  1. 更改 Blazor Server 项目中 wwwroot 文件夹的 site.css 的名称。

  2. 删除 Blazor Server 项目中的 wwwroot 文件夹。