asp.net user exits the update implementation code online

  • 2020-05-10 17:56:04
  • OfStack

The main problem is how to update the user's online list when the browser is closed

The idea circulating on the Internet is to keep ajax sending requests asynchronously, letting users know they have closed the browser when they no longer want to
 
 var x=0; 
  function myRefresh() 
  { 
  var httpRequest = new ActiveXObject("microsoft.xmlhttp"); 
  httpRequest.open("GET", "test.aspx", false); 
  httpRequest.send(null); 
  x++; 
  if(x<60) //60 Second, that is Session The real expiration time is 30 minutes  
  { 
  setTimeout("myRefresh()",30*1000); //30 seconds  
  } 
  } 
  myRefresh(); 

Set in web.config:
< sessionState mode="InProc" timeout="1" > < /sessionState >

Related articles: