I have an ASPX page which when is submitted into a new tab starts a server side process. Sometimes the process takes too long and a user closes the tab the page is running in. However, the process continues running and that creates a big problem. My question is why the process continues running and how can I kill it when the tab is closed. I do have a code in the code behind where I can kill the process, I just can't find a way of executing it. Please, help. Release is coming. Closing Browser actually help.
Thanks
code to detect tab closing event:
window.addEventListener('beforeunload', function (e) {
e.preventDefault();
e.returnValue = '';
... execute server code
});
The event is not detected.
If you have a way to cancel the process on the back-end, the best you can do is use the JavaScript events onunload and onbeforeunload to detect when the user closes a tab, and then send a request to kill the process.