public void ProcessRequest(HttpContext context) { context.Response.ClientDisconnected += new EventHandler(OnClientDisconnect); // your code here } public void OnClientDisconnect(object sender, EventArgs e) { HttpContext context = (HttpContext)sender; // log client abort }
public void ProcessRequest(HttpContext context) { CancellationTokenSource cts = new CancellationTokenSource(); context.Response.ClientDisconnected.Register(() => cts.Cancel()); // your code here if (cts.Token.IsCancellationRequested) { // operation cancelled } }Package library: System.Web.