Reuse the same connection in the R signal when navigating different pages

I have an MVC project with several pages.

I have a lengthy process that updates the client process. However, this update is sent only to one client, and is not broadcast to everyone.

Clients.Client(ConnectionId).sendMessage(msg);

In my layout.cshtml, this is how I connect to the hub

    var serverHub = $.connection.notifier;
    window.hubReady = $.connection.hub.start(function () { });

The problem is that when I go to another page, I no longer receive messages from signalr, because the connection identifier has changed.

How can I solve this problem, so my signalr concentrator can still send messages to one client, and the client goes from page to page.

+5
source share
1 answer

. : - SignalR 1.0 factory.

, OnDisconnected, , .

, :

  • , SignalR
  • , = > TryCreateUser ( , ).
  • → SignalR
  • , SignalR.
  • , , cookie, - , , = > TryCreateUser (userData) ( , ).
  • .

.. , SignalR, , .

+5

All Articles