Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8616419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:36:55+00:00 2026-06-12T05:36:55+00:00

Good morning everyone, I am working on a legacy ASP Classic application which needs

  • 0

Good morning everyone,

I am working on a legacy ASP Classic application which needs some upgrading and refactoring. One of the biggest improvements that needed to be made was to speed up the app by caching the results from database. This I have been able to do successfully by caching them to .dat files. This application follows a specific path so I have been deleting the unused cache files after I am done with them. However, on the final .asp page of the application (PV.asp), the files are getting deleted when they shouldn’t be.

My intention is this,

 <input type="button" value="Done"  style="width: 56px; height: 40px" onclick="finish()"    />

^ this is the code for the “Done” button, it calls the finish() function. Which is below:

    function finish() {
        var size = "<%response.write(size) %>";
        if (size == "0") {
        var done = confirm("All Items mod, would you like to save?");
        if (done == true)
        {
            if (window.XMLHttpRequest)
            {
                xmlhttp = new XMLHttpRequest();
            }
            else
            {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            var concode = "<%=Replace(concode, "\", "\\" )%>";
            xmlhttp.onreadystatechange=function()
            {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                    {
                        document.getElementById('concode').value = concode;
                        document.forms["confirm"].submit();
                    }
            }
            <%if NOT rsTrxTy.EOF then
            if rsTrxTy.fields("TYPE").value = "TO" then%>
            ~Stuff happens here~
            <%end if 

            if rsTrxTy.fields("TYPE").value = "TI" then%>
            ~Stuff happens here~
            <%end if
            end if

            if NOT rsOrdrs.EOF then%>
             ~Stuff happens here~
            <%end if %>
            <%
            dim fso
            Set fso = Server.CreateObject("Scripting.FileSystemObject")
            fso.DeleteFile "C:\M\cache\rstrxis-" & Session.SessionID & ".dat"
            fso.DeleteFile "C:\M\cache\rstrxos-" & Session.SessionID & ".dat"
            fso.DeleteFile "C:\M\cache\rstrxty-" & Session.SessionID & ".dat"
            fso.DeleteFile "C:\M\cache\rsords-" & Session.SessionID & ".dat"  %>
        }
    }
    else {
            alert("All items have not been mod.");
        }
    }

When the user clicks the “Done” button, the changes made to the items are committed to the database. My intention is that when this action is being performed, the cached files are deleted. However, the DeleteFile command runs even if the user doesn’t click the “done” button. It runs once the page has finished loading. This causes problems since the page will try to load from the cached file which were deleted when PV.asp was loaded. Since this app is intended to be used almost constantly without the window being closed, the session ID will remain the same which leaves not deleting the cached files out of the question (since when the app is restarted it will attempt to load what has already been cached).

My question is, why are the files being deleted when they are supposed to be contained in a javascript function that only executes when the user clicks done? I am not experienced in ASP/Javascript as this project was forced on me so I apologize if this is a simple question but I am honestly stumped.

Note- Moving to ASP.Net is out of the question. Please do not suggest this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:36:56+00:00Added an answer on June 12, 2026 at 5:36 am

    That’s not how ASP works. The ASP code segments (the stuff between <% ... %>) is calculated only once when the page is first loaded.

    For example, if you do this:

    <script type="text/javascript">
    function finish() {
    <%              
    dim fso
    Set fso = Server.CreateObject("Scripting.FileSystemObject")                  
    fso.DeleteFile "C:\M\cache\rstrxis-" & Session.SessionID & ".dat"               
    fso.DeleteFile "C:\M\cache\rstrxos-" & Session.SessionID & ".dat"              
    fso.DeleteFile "C:\M\cache\rstrxty-" & Session.SessionID & ".dat"              
    fso.DeleteFile "C:\M\cache\rsords-" & Session.SessionID & ".dat"  
    %>
    }
    </script>
    

    The fso.DeleteFile function invocations are called WHEN THE PAGE LOADS, not when the JavaScript function is fired.

    Why? When the server recieves a request for the ASP page… it first goes through and processes all the dynamic code segments between <% %> with real HTML and then returns to the user a page that they can load. Note: A browser has no idea how to process <% %> tags! The server is the only one who can do that.

    Does this make sense?

    You have a few options to go about what you are actually trying to do here, but I would go with performing an Ajax request to a new ASP page that all it does is call the fso.DeleteFile commands you need.

    Here is an example: http://www.degraeve.com/reference/simple-ajax-example.php

    Other options would be to use a get/post to the same page with a parameter that will trigger the DeleteFile. You’d have to redesign a bit to use that. I recommend the ajax solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good morning everyone! I'm doing a distributed application using .NET 4.0, C# and Remoting
Good morning everyone, I have a question about J2EE framework. since ASP.net 3.5 mvc
Good Morning/Afternoon all, I have a ASP:grid which displays current versions of Terms and
Hello good morning everyone, I am developing an iphone app which provide push notification
Good morning, I inherited some legacy code at work and it is using a
Good morning, everyone. I need some query help. You can assume I understand relatively
Good Morning, I have an application which allows users to slide values for different
Hello Everyone and Good Morning, I am working with the page: http://702wedding.com/live/ And it
Hello good morning everyone, i have an iphone app which is still in development
Good morning, I've got an ASP.NET MVC VB2008 .NET 3.5 project I'm upgrading to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.