Run ASP Script on Close of Windows Explorer


  I want to Run Server Side Script when use close application by close button of Explorer of ALT + F4.

  just like in VB Application we have event QueryUnload for Form.
covisibleAsked:
Who is Participating?
 
lostcarparkConnect With a Mentor Commented:
The only way I can see you could do it would be to add a JavaScript handler to the "onUnload" event of the ASP page.

This would need to load your page, but I don't think it could do it in the window that the user is closing, so the only option I can think of is to use a "window.open()" to open your page in a new window. You could set it to open a very small window out of the way.

This would load your ASP page, allowing you to do any cleanup on the server.

I would suggest putting a "window.close()" in the onLoad event of the page to close the window again.

The major problem with this approach is that it's likely to be blocked by a lot pop-up blockers, so unless you have control over your user environment you may have to find another way.

Personally I would advocate designing an application in such a way that your users never need to explicitly log out or close the application, as it's just too hard to predict what will happen on the client side.
0
 
jhanceCommented:
I don't think there is any event for this so I don't think you can do what you want here.  

Perhaps there is some "trick" to get something similar that someone else knows...
0
 
bgloddeCommented:
I agree 100% with lostcarpark's points ^

You could try using the Session_OnEnd event in global.asa - theoretically, once the browser closes, the session should end soon thereafter.
Not sure how important the timing is in what you want to accomplish...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.