How to make global notification?

Please suggest.
I want to make global notification component. I try to make it with SignalR it working with one page only.

How to click test button alert all clients ?

You can try registering the NotificationService via the AddSingleton method instead of AddScoped.




1 Like

I tried notification still show in one page.

Do you have an example code on github ? if yes please share me.

I tested it in our sample application and here is what I observed.


The same thing won't work in a WebAssembly app though - AddSingleton won't add a global instance of the service because every WebAssembly app has its own instance in the client browser. A different approach would be needed - some server-side code which broadcasts messages to all clients. Perhaps you need SignalR for that. Here is a blog post that found which shows how to use SignalR with Blazor WebAssembly: Using Blazor WebAssembly, SignalR and C# 9 to create Full-stack Real time Applications | DotNetCurry

1 Like