自动重新连接Blazor服务器端 [英] Auto reconnect Blazor Serverside

查看:499
本文介绍了自动重新连接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.

每次更新代码库或Internet损坏或类似情况时.

Each time I update the Codebase 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).

有没有可能/github repo或类似的东西可以帮助我?

Is there any possibility / github repo or something like this that could help me?

谢谢!

推荐答案

您可以尝试以下代码:

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

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

这篇关于自动重新连接Blazor服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆