Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR Maintaining Connection Id on browser refresh

I'm developing a chat application using signalr and asp.net mvc 4. If a user added for first time - it will assign a connection id and he chat with other clients but if he refreshes his page he will assign a new connection id.

My question is how to maintain the connection id of the user on browser refresh?

Any help will be appreciated.

like image 686
Sumit Kesarwani Avatar asked Nov 11 '22 11:11

Sumit Kesarwani


1 Answers

If a user is added for first time - it will assign a connection id that time you store in Session or some specific static variable if page will refresh that time check Session variable is empty or not if not pass the current id

if(Session["id"] != null )
{
   -- use last added id
}

I think this can be help you.

like image 143
Mayank Patel Avatar answered Nov 15 '22 11:11

Mayank Patel