1

I have a ASP.NET MVC web application that needs to notify the server when a user leaves. To do so, I make an Ajax call posting a string to the server.

Currently, I'm making the call on the window.onbeforeunload event, but to do more than show the user a message, this event is very unreliable.

The other ways I come up to do this was by using SignalR to do a ping-pong request or to control something (session?) on the server side.

What's the best approach to make the server know when a user leave the application?

Andre Nascentes
  • 391
  • 4
  • 14

1 Answers1

1

Here's an aproach for detecting iddle time in a page Detecting idle time in JavaScript elegantly. And to detect disconnection I suggest you use handsaking approach (that can be used with signalR as you pointed out): http://en.wikipedia.org/wiki/SYN-ACK#Connection_establishment

Community
  • 1
  • 1
Augusto
  • 1,234
  • 1
  • 16
  • 35