Search code examples
c#asp.net-coresignalrsignalr.client

how refresh/reload web page from another browser


I want open this web app on different browsers then do some actions in one of them (ex run some post request) next I want that in all other browsers page will be reloaded

I'm not completely sure, but, perhaps, "signalR javascript client" will help me?


Solution

  • open this web app on different browsers then do some actions in one of them (ex run some post request) next I want that in all other browsers page will be reloaded

    perhaps, "signalR javascript client" will help me?

    Yes, you can achieve it by integrating ASP.NET Core SignalR functionality into your project to push specific notification to connected SignalR JavaScript clients, then the JavaScript client can update DOM content or refresh current page once received that specific notification message.

    Besides, if it requires sending notification message from controller action(s) in your development scenario, you can inject an instance of IHubContext in your controller, then use that instance to send message(s) to client(s) as if you were in the hub itself.

    For detailed information about "Send messages from outside a hub", please check this doc:

    https://learn.microsoft.com/en-us/aspnet/core/signalr/hubcontext?view=aspnetcore-5.0#inject-an-instance-of-ihubcontext-in-a-controller