I'm having C# self hosted server application using SignalR. My client is SPA (angualr,javascript HTML5).
My application have some termination process which should run when leaving the page (running when OnBeforeUnload occurs and the user asks to leave...). The termination process contains some server calls.
Till today I worked with WebSockets and all worked well. I'm now trying to deploy my application on a server machine that doesn't support WebSockets so I'm using SignalR instead.
My problem is that SignalR closes/disconnects the connection when "OnBeforeUnload" happens. This means that I can't perform the termination process.
I tried to workaround this by creating new connection but it also fails to open.
Is there a way to overcome the above problem?
thanks, R.
You can use the connection lifetime event OnDisconnected instead of making an explicit call to the server. Using OnBeforeUnload for asynchronous code is not a good idea in general.