The browser close is a browser functionality,
and is purely a client-side event that has nothing to do with your server-side
code and will trigger no events to indicate that the browser was closed.You have
to use onbeforeunload event to trigger a popup to notify users when the browser
is about to close, You can then make an AJAX call to invoke a server-side
method ( but you cannot guarantee that your server-side code will execute).
in mind that this event will also trigger when the user clicks on the hyperlink
or attempts to close the browser window.
want to try decreasing the duration for your authentication cookie (if you are
using Forms Authentication). This will essentially log your user out if they
have not been active within the application past the duration of your timeout,
which if set to a small value will likely expire prior to the user returning to
also consider using a real-time technology like SignalR to essentially
"track" a user throughout your application using their Connection ID
and then if you see that they are idle after a certain duration, handle that
accordingly and call the Session.Abandon() method.