Groups | Blog | Home
all groups > inetserver asp general > august 2003 >

inetserver asp general : Stumped - page executes twice sometimes (even thrice occasionally!)


Manny
8/28/2003 11:06:22 PM
I have a web form "Page1.asp" and it reads data from a database, does some
calculations, and displays the records in pages. Works fine.

I have a button that displays on the page, defined as <input type="button"
onClick="OutputData()">

The OutputData() function is a javascript function that simply does this:

window.location = "Page1.asp?Flag=1";

This "re-executes" Page1.asp, but with a flag set in the query string. The
logic in Page1.asp writes the data to a file when this flag is set instead
of paging it to the browser - it sends NOTHING to the browser when that flag
is set.

At the end of the data file generation, Page1.asp does a Response.Redirect
to Page2.asp, passing it the filename in the query string.

Page2.asp uses a COM object (DLL) we wrote in VB6 to further manipulate the
data and the end result is a PDF file that gets sent to the browser through
Response.BinaryWrite from an ADO binary stream. Page2.asp outputs no HTML
itself - only the PDF data.

What has me stumped is that Page2.asp is executing _multiple times_.
Usually it executes twice, but sometimes it executes 3 times. I can tell
because the COM object it uses writes some info to a log file. I clear the
log file, click on the button on Page1.asp _one_ time, and the log shows the
COM object being executed 2 or 3 times in a row. I cannot figure out why.
There are no loops in Page2.asp - it is a fairly simple ASP script, no
functions or sub's - just about 20 lines of script.

Page1.asp is definitely not redirecting to it multiple times. I put some
code in Page1.asp to log a timestamp each time it redirects to Page2.asp and
it only does it *once* after I click the button.

I put some code in Page2.asp to increment a Session variable and it does
increment it multiple times after a click, so it is definitely Page2.asp
that is executing multiple times. I did the same in Page1.asp and it
increments only one time per click.

Any ideas why this might be happening?

TurboDuster
8/29/2003 9:46:14 AM
[quoted text, click to view]
Manny,
Your problem MAY be similar to one I'm having. I submit a form to an
ASP page using a single button click, and it ends up getting submitted
twice. I've been able to determine by using NETMON to capture the
packets exchanged that after the first correct submission the client
then executes another submission, this time with cookie data, which
I assume the server is asking for right after the first correct submission.
Oddly, if the first submission used GET as a method, which seems to be
your case, all the form data gets resubmitted with the cookie data, so
everything actually works for my needs.. See if you can get a packet
capture and examine the data for a second redirect the also has cookie
data in it. Also turning Sessions off might solve the problem,
<%@ EnableSessionState = False %>
even just to see if cookies are the culprit.
Hope this helps,
TurboDuster
Michael D. Kersey
8/30/2003 2:13:37 AM
[quoted text, click to view]

Instead of describing of what you *believe* the code does, please post
the code itself. That way we might be able to determine *what the code
Manny
8/30/2003 10:36:13 AM
In general, I agree that posting code would help in the analysis. But in
this case, I really believed that it was not the code that was causing the
problem.

And it turns out I was right in that assessment. I found that it is not the
code, but IE/Acrobat causing the problem:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q293792


[quoted text, click to view]

AddThis Social Bookmark Button