Hi here I\'m trying to call a [webmethod] on bodyunload method.
But it is getting fired on page load itself only. How do i prevent it?
Here\'s the code I am
I have tested with below code and it is working fine.
In Aspx page
In Codebehind
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
public partial class ClearSessionOnPageUnload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static void AbandonSession()
{
HttpContext.Current.Session.Abandon();
}
}
You can put breakpoint at AbandonSession method to verify that it is getting hit at unload.