Run ASP Script on Close of Windows Explorer

Posted on 2006-05-02
Last Modified: 2010-04-17

  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.
Question by:covisible
    LVL 32

    Expert Comment

    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...
    LVL 5

    Accepted Solution

    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 "" 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.
    LVL 13

    Expert Comment

    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...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Title # Comments Views Activity
    EvenOdd challenge 10 67
    Excel object stays open 19 56
    noX challenge 17 53
    Path of Workbook 3 30
    RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    6 Experts available now in Live!

    Get 1:1 Help Now