ASP page executing twice when ContentType="application/pdf"
Posted on 2001-06-19
We are trying to read a .pdf file from a file server and return it to a new browser window. Which .pdf file we choose depends on some form fields. But I have stripped out all the extraneous stuff from these two files to illustrate the problem. First, here is the form:
<FORM name="form1" method="post" action="pdfDisplay.asp" target="newWin">
<INPUT type='hidden' name='myfield' value='x'>
Here is the asp page:
stop 'for debugging
Response.Buffer = TRUE
'Set oMyObject = Server.CreateObject("BinReadObject.BinRead")
'create the binary stream
'vntStream = oMyObject.readBinFile("F:\Data\Sample.pdf")
Note that the code for reading and writing the .pdf file is commented out. When we submit the form as it is above, the debugger executes the asp page twice thru ... first hitting the "stop" command and then stepping thru to the response.end, then it inexplicably starts over again and repeats one time.
However, if we comment out the response.contenttype setter, it only executes once. We could normally live with this except that on the second time thru the Request object has no form data in it and so we cannot determine what the user is requesting. Also, the buffering and flushing does not appear to make any difference.
Has anyone seen this weirdness before? If so, how did you resolve it?