Click here to Skip to main content
14,922,630 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to end user session when browser closed.I am using fllowing Code.It's Not working.What is the error of this Code?


C#
using System.Web.Services;

[WebMethod]
public static void AbandonSession()
{
  HttpContext.Current.Session.Abandon();
}



XML
<script type="text/javascript">
  function HandleOnclose() {
    alert("Close Session");
    PageMethods.AbandonSession();
  }
  window.onbeforeunload = HandleOnclose;
 script>
Posted

1 solution

The first result when I Googled - end session on browser close asp net[^] is a CodeProject tip - How to end user session when browser closed[^]

Please search before you ask.
   
Comments
breaker-code 5-Dec-14 6:09am
   
I search.i try you link.it's NOt working.
Ankur\m/ 5-Dec-14 6:13am
   
There is a discussion board at the end of the article. You can post your question there. Please be specific and describe what exactly is not working.
Also there are many more discussions in the Google search result. Read them and try. Of course most of the solutions provided there are already used by programers.
Thanks7872 5-Dec-14 6:24am
   
And not working is not at all informative.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900