Page_Load event firing twice when loading PDF

  • Thread starter Thread starter andrei
  • Start date Start date
A

andrei

Hi Group,

I'm having a problem with the Page_Load event firing twice when loading and
displaying a pdf.

I've seen other people here encountered the same problem, but unfortunately
the discussion thread did not end with a positive answer/solution.

(see thread with subject "Page_Load Event Fires Twice When Sending Down a
PDF")

In fact, I have another form, with an iframe element on it, which loads this
form.

I'm using IIS 5.0, the above form is not the default form for the project
and the SmartNavigation is set to false(this goes for both forms).

Could anybody give some hints, please ?



The code in Page_Load is as follows:

*************************************

Dim result() As Byte

result = mReport.GetStream(strParams) ' here mReport is an object that
loads the pdf from a database and returns it as a byte array

Dim strContentType As String = ""



strContentType = "application/pdf"



Response.Clear()

Response.ClearContent()

Response.ClearHeaders()

Response.ContentType = strContentType '"application/pdf"

Response.AddHeader("content-length", System.Convert.ToString(result.Length))

Response.BinaryWrite(result)

Response.Flush()

Response.Close()

**************************************

Thank you,

Andrei.
 
this is by design. when IE downloads a content type that it uses external
viewer such as pdf, it does the following:

1) detects content type requires external viewer
2) re-requests the content with a special header to verify the content-type
3) loads the external viewier
4) passes the url to the viewer so the viewer can download the content

of course if you have anonymous turned off, there are a few more trips for
authenication.

-- bruce (sqlwork.com)
 
Back
Top