2
The idea is to keep the user logged in to Chat as he navigates the pages.
Layout of the components on the page
Layout.cshtml
function iniciarChat() { var chatHub = $.connection.chat; $.connection.hub.start(); }
Index.cshtml
iniciarChat();
Today the structure is like this. However when the user clicks on some link that makes a Postback, it is disconnected from the Chat. And when it goes back to Index.cshtml, it reconnects to Chat again.
I wonder if there is any way to keep the user connected to Chat even if he makes a Postback.
Hello @Maiconcarraro ! the problem is that when the user changes pages, the javascript code of the Layout and Index pages is executed again and so the hub reconnects.
– alexander Pataki
@alexanderPataki There’s no way you can’t run javascript if it won’t receive the calls, what you do is avoid creating a NEW session
– Maicon Carraro
How can I do that? Because when the start methodChat() is executed, it is as if a bridge was created between the client and the Hub, and if it exits the index.cshtml, it soon falls into the Ondisconnected method of the Hub.
– alexander Pataki