Automatic UI updates with Blazor

Jeff Bowman 101 Reputation points
2024-05-14T23:20:47.5966667+00:00

Using a .NET 8 Blazor WebApp, I hope to build an application whose pages automatically send updates to all users. For example, when Joe adds a payment to an invoice, Sue (who is viewing the same invoice) should see the new balace reflected on her screen the moment Joe clicks the Save button.

Will this be possible without wiring up a special SignalR hub for each page/component? I've read that Blazor uses SignalR under the hood, so I'm hoping this can be accomplished without a lot of complex (and error-prone) extra work.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,467 questions
Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,427 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 58,121 Reputation points
    2024-05-15T03:28:45.7666667+00:00

    Blazor Server uses signal/r for the JavaScript render / event to communicate to the server. Its a dedicated connection only for Blazor jsinterop messages.

    you would need a second signal/r hub that the Blazor server code communicates to other Blazor server instances. See

    https://learn.microsoft.com/en-us/aspnet/core/blazor/tutorials/signalr-blazor?view=aspnetcore-8.0&tabs=visual-studio

    0 comments No comments