Blazor 服务器显示 'Invocation canceled due to the underlying connection being closed'

Blazor server showing 'Invocation canceled due to the underlying connection being closed'

我们有一个 Blazor 服务器端 Web 应用程序,其信号器托管在 IIS 上。我们为 Blazor.start() 添加了带有 reconnectionHandler 和 reconnectionOptions 的 EventListener。当作为先前选项卡的一部分打开网站或在长时间睡眠后打开时,网站显示“发生错误。此应用程序可能不再响应,直到重新加载。”错误和控制台错误显示

Error: The list of component records is not valid.

Uncaught (in promise) Error: Invocation canceled due to the underlying connection being closed.
    at e.connectionClosed (blazor.server.js:1:27242)
    at e.connection.onclose (blazor.server.js:1:17377)
    at e.stopConnection (blazor.server.js:1:61423)
    at e.transport.onclose (blazor.server.js:1:59077)
    at e.close (blazor.server.js:1:47811)
    at e.stop (blazor.server.js:1:47400)
    at e.<anonymous> (blazor.server.js:1:52950)
    at blazor.server.js:1:49394
    at Object.next (blazor.server.js:1:49499)
    at a (blazor.server.js:1:48266)

IIS 中没有负载平衡并且启用了 websockets。我在 Blazor github 上查看了一下,一些解决方案建议的解决方案是在 _Host.cshtml 中添加一个无缓存元标记,例如

<meta http-equiv="Cache-Control" content="no-store" />

即使添加了这个,我们仍然会出现上述错误。我们最后遗漏了什么吗?任何帮助将不胜感激。

正常使用应用不会出现该错误。信号器工作正常。

我之前遇到过完全相同的问题并在 github detailing the same issue

上发现了这个问题

正如史蒂夫所说,将以下内容放在 _Host.chtmlbody 标签内,而不是将其作为元标签。

@{
    Response.Headers["Cache-Control"] = "no-store";
}