Print Page | Close Window

solution to prevent page from reloading??

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=7232
Printed Date: 31 March 2026 at 11:22pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: solution to prevent page from reloading??
Posted By: probichaud
Subject: solution to prevent page from reloading??
Date Posted: 13 November 2003 at 11:41am

Hello,

does anyone know of a simple asp solution/script to prevent duplicate credit card transactions/submissions from occurring?

I have a credit card processing page that I don't want users to be able to reload/refresh. This causes a additional request to the payment gateway resulting in a duplicate transaction. I thought about doing a database check on user name first but was hoping there would be a better solution...

Thanks for any suggestions or insight on this problem.

probichaud.




Replies:
Posted By: michael
Date Posted: 13 November 2003 at 12:29pm
You can create a unique GUID or Session ID on entering the site. Use that in the database as the purchase Key and if someone hits refresh raise an error that the form has already been submitted. I wouild clear that variable though after checkout in case the customer decides to come back and purchase something else.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: probichaud
Date Posted: 13 November 2003 at 12:45pm

Good idea! Thanks a lot.

 



Posted By: rjohnmatts
Date Posted: 05 December 2003 at 12:40pm

Another way to do this is to use a javascript function to store the current time in a hidden field.  When the page is submitted, call the function, and then submit the page. Server Side, store the value in the session, and just check the incoming value to see if it is the same as the one stored in the session.

example:

  //Client code:
  function preventResubmit(){
   //this function will insert the current time into the preventResubmit field
   //the value will be stored in the session and a comparison will be made on subsequent actions to see if the time is the same
   //in the case that it is, the user will be logged out
   var theDate = new Date();
   var milliDate = theDate.getTime();
   document.formName.preventResubmit.value = millisDate;
  }
  <input type=hidden name=preventResubmit value="">
  
  //Server code:
  String sessionPreventResubmit = (String)session.getAttribute("preventResubmit");
  String clientPreventResubmit = (String)request.getParameter("preventResubmit");
  if(localPreventResubmit != null){
   if(sessionPreventResubmit.equals(localPrev entResubmit)){
    response.sendRedirect("error.htm");
   }
   else{
    session.setAttribute("preventResubmi t", localPreventResubmit);
    //jsp or servlet content here
   }
  }



Posted By: ljamal
Date Posted: 05 December 2003 at 7:36pm
Another way is to post the data to a page other than the final destination and then do a redirect after processing. Then if they refresh the page they are only getting the final page which does not process CC again.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net