OnInit firing twice with contenttype set to application/pdf?

S

Sean Kraft

Hello,

I am generating a PDF and writing its bytes to the browser using
Response.BinaryWrite(). Before I do this I set the
response.contenttype = "application/pdf".

When I run in debug I see that the onInit event gets fired twice,
causing my PDF to be generated 2x, to be sure that the debugger is not
causing the problem, I write out a text file in the onInit and run it
compiled, 2 events are firing compiled also.

Here is my code (if I remove Response.ContentType, and
Response.AddHeader onInit only fires once):

//Execute the report
byte[] b = RetrieveReportBytes();

//Return the results
Response.Clear();
Response.ContentType = sContentType;
Response.AddHeader("Content-Disposition", "inline;
filename=Test.pdf");
Response.BinaryWrite(b);
Response.Flush();
Response.End();


I have used this technique many times in the past, and I'm stumped as
to why it now causes this strange behavior.

Thanks,
Sean
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top