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

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

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

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