I am using the Blazor server-side.
When the Blazor App disconnect to the remote server, it will shows this:
I want to change the text ('Could not reconnect to the server...' and so on) of the image above.
I want to change it to the language of our country.
I found the file of the project but found nothing about this.
How can I change it? Thank you.
For the javascript side of things Blazor exposes a tiny API via the
window.Blazor
object.One part of this API is the
defaultReconnectionHandler
which allows you to customize the reconnection experience including setting different options for the number of retrys etc.However, it is also possible to just swap out the logic for displaying the
ReconnectionDisplay
A simple implemenation looks like this and enables you to to get controll over the process:
The Blazor App will check whether there's a html element with id=
{dialogId}
in the page:class
will be :components-reconnect-show
when attempting to reconnect to the server,components-reconnect-failed
when it failed to connect to server.components-reconnect-refused
if the browser reaches the server while the server rejects the connection activelyBy default, the
dialogId
iscomponents-reconnect-modal
. So you can create an element in the page and use CSS to control the content and styles as you like.Demo:
For example, I create three parts of content to display within the
Pages/_Host.cshtml
:And then let's add some CSS to control the style:
Finally, we'll get the following message when attempting to connect or failing to connect: