As when browser or page crashes I need to detect it in the server-side what I actually found is this solution so far when the browser closes it reads as below.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="WebApplication2010.WebForm3" %>
<%@ Register Assembly="AjaxControlToolkit, Version=3.0.30512.17815, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"
Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Handling Browser Close Event at Server Side: ASP.NET</title>
</head>
<body onunload="deleteRecord();">
<script type="text/javascript" language="javascript">
function deleteRecord() {
//this method will call server-side method
PageMethods.deleteRecord();
}
</script>
<form id="form1" runat="server">
<div id="div1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
Click on Close Button
</div>
</form>
</body>
</html>
This is the client page above and the server code is below written.
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static void deleteRecord()
{
// You can write any logic you want to perform when the browser is getting closed
System.Diagnostics.Debug.Write("You can write your logic here");
}
Here is the excerpt which I used - https://www.dotnetspider.com/resources/30715-Handling-Browser-Close-Event-at-Server-Side.aspx
Any suggestions might help out in this browser crash context.