473,770 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OnInit firing twice with contenttype set to application/pdf?

Hello,

I am generating a PDF and writing its bytes to the browser using
Response.Binary Write(). Before I do this I set the
response.conten ttype = "applicatio n/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.Conten tType, and
Response.AddHea der onInit only fires once):

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

//Return the results
Response.Clear( );
Response.Conten tType = sContentType;
Response.AddHea der("Content-Disposition", "inline;
filename=Test.p df");
Response.Binary Write(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
Nov 18 '05 #1
0 1177

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3181
by: Manny | last post by:
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";
7
2711
by: Patrick Ruhnow | last post by:
Hello, i have an ASP Page that generates a PDF document. After the generation i save the generated document as a file. all works fine. the only strange thing is, that my document is stored twice on the filesystem. why is the page loaded twice???
0
1797
by: Nathon Dalton | last post by:
I need help! A page I'm working on builds an HTML string based on a bunch of data in different tables and databases. Then it does a response.write with a contenttype of application/msword. The result being an HTML page that's editable in word, inside of Internet Explorer. The problem I'm getting is that the page is loading twice. It's blowing out session information, so I can't keep track of how many times it has ran. Here's the code. ...
0
1526
by: Andy | last post by:
Visual Studio 2003 web form problem using C#. My Page_Load or OnInit routines seems to be called twice for every post back to the server. I think it's the Oninit thats being called twice, the sequence of events is as follows This bit of code is fired first-
1
2244
by: | last post by:
Hi, All, I'm having problems getting OnInit to fire in my UserControl, when I use a custom template to render the control. The control will render to the browser and it wasn't until I needed to perform some initialization in the OnInit event did I realize that this event was never firing. Two Question:
7
2101
by: Jay Douglas | last post by:
Hello all, I have a asp.net page that creates a pdf on the fly and sends the pdf down to the browser. When calling the page up in IE the Page_Load event is fried twice. This doesn't happen with mozilla, just IE. This is a big problem because the PDF can be 20+ MB in size and is causing some serious performance issues. Writing the PDF to the filesystem then a redirect is not an option. I was wondering if anybody has any input on how...
4
1758
by: Vikram | last post by:
i am using following code in button click... of asp.net code behind page Response.Clear() 'clears the current output content from the buffer Response.AppendHeader("Content-Disposition", _ "attachment; filename=Add2Calendar.vbs") Response.AppendHeader("Content-Length", mStream.Length.ToString())
1
2554
by: Sridhar | last post by:
Hi, I am trying to display a pdf file on the web. It is working fine but the Page_Load method is running twice before displaying the page. Here is the code that I am using Private Sub ReadPdfFile(ByVal strFilepath As String) 'Create WebClient Object Dim objWebClient As New WebClient 'Create Byte Array to download data
4
3106
by: L. Scott M. | last post by:
I am invoking a file download using the following code: Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + downloadFile.Name); Response.AddHeader("Content-Length", downloadFile.Length.ToString()); Response.ContentType = "application/octet-stream";
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10257
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10037
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8931
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.