OnInitializedAsync method, connect to the Web API.
ReceiveMessage method, used in the SignalRHub class.
ReceiveMessage method, concatenate the name and message parameters, and append them to a list.
The StateHasChanged method will update the bindings in the HTML. The SendMessage method will invoke the Send method in the hub with name and message parameters.
Blazor Server
In the server code, configure SignalR in the Startup.cs class file as follows.
And then create a SignalR hub class as follows.
Blazor client
Create a Blazor app and add the package Blazor.Extensions.SignalR to the client. Then write the code to connect the Hub and event handler as follows.
The StateHasChanged method will update the bindings in the HTML. The SendMessage method will invoke the Send method in the hub with name and message parameters.
need an explanation for this answer? contact us directly to get an explanation for this answer