自动重新连接 Blazor 服务器端

问题描述:

Blazor 服务器端(dotnet 核心 3.1)

Blazor serverside (dotnet core 3.1)

我遇到了在客户端显示的问题:

I run into the problem that on customer side this is shown:

无法重新连接到服务器.重新加载页面以恢复功能.

Could not reconnect to the server. Reload the page to restore functionality.

每次我更新代码库或互联网都坏了或类似的东西.

Each time I update the code base or internet is broken or something like this.

现在的目标是它应该在服务器再次返回时(或在某个时间间隔内)重新加载页面.

Now the goal is that it should reload the page as soon as the server is back again (or in some interval).

有什么可以帮助我的可能性吗?

Is there any possibility that could help me?

你可以试试这个代码:

<script src="_framework/blazor.server.js"></script>

<script>
   Blazor.defaultReconnectionHandler._reconnectCallback = function(d) {
        document.location.reload(); 
   }
</script>