服务器端 Blazor 在 firefox 中调试时获取授权错误 (401)

Server side Blazor gets authorization error (401) when debugging in firefox

我刚开始接触 blazor(来自 mvc)。我在 Visual Studio 2022 年创建了我的第一个服务器端测试项目,遵循两个教程,到目前为止我没有创建或更改任何内容。我选择了 windows 身份验证,因为这将是我的大多数项目所需的身份验证类型。当我尝试在 Firefox 中 运行(即调试)这个项目时,除了一个空白页面之外什么也没有显示。当我检查控制台输出时,只有一条错误消息:

The character encoding of the plain text document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the file needs to be declared in the transfer protocol or file needs to use a byte order mark as an encoding signature.

当我尝试重新加载页面时,顶部显示 HTTP 错误 401(未经授权)。

项目选项:

当我第一次尝试 运行 应用程序时,我 visual studio 创建了一个测试证书。

我曾经在使用 firefox 调试 mvc 项目时被要求提供登录数据,但是当我尝试调试我的 blazor 项目时却没有得到提示。交叉检查:我可以 运行 Edge 中的应用程序;据我所知,Edge 会自动获取 windows 登录名,而 firefox 需要配置才能执行此操作。但是让 firefox 自行获取 windows 登录并不能解决我的问题。

我的一位同事找到了解决方案:我必须在调试按钮下的菜单中选中“IIS Express”选项。所以是visual studio和firefox认证方式的兼容性问题