[Solved] How to get each web user’s status is online or offline on server side ?


when user was close the tab or browser means that user can’t online so
i want to manage some status using that Online or offline status.

You can get hold of the close event window.onbeforeunload of the tab or Browser. And within this event execute a ajax call to server by passing the userId, Then in server you will just have to update your DB to say the user is offline.

Example of how to catch the close event, Working Example

JavaScript

window.onbeforeunload = function () {
    //your ajax call to server
};

Jquery

$(window).on('beforeunload', function(){
  //your ajax call to server
});

implementing Ajax call in Javascript and in Jquery

Example of your ActionResult in server,

public ActionResult SignOutUser(string userId){
  // your code to log off the user (either expire his cookies or log offline status in db)
}

This is the basic Idea of how such scenarios are handled.

solved How to get each web user’s status is online or offline on server side ?