473,494 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Page_Load Event Fires Twice When Sending Down a PDF

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 to correct
the issue or when MS is going to be able to fix this bug. The
Autoeventwireup is set to false. (I've also trited using Reponse.End() and
Response.Flush() )

Here is the code for the Page_Load event:

int docId;
ErezDoc doc;
byte[] b;

if (Request.Params["d"] != null)
{
if((docId = Convert.ToInt32(Request.Params["d"])) > 0)
{

doc = new ErezDoc(docId);

b = doc.GetData();

Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", b.Length.ToString());
Response.AddHeader("content-disposition", "inline; filename=" +
doc.DocId.ToString() + ".PDF");
Response.BinaryWrite(b);

doc.Clear();
}
}
--
Jay Douglas
Fort Collins, CO


Nov 18 '05 #1
7 2085
Hi Jay,

I've got a couple of questions for you:
What version of the Framework are you using? Also, is this page set as the
default page in IIS? Third, is smartnavigavtion set to true for this page?

This combination of settings has been known to cause the page_load event to
fire twice in certain circumstances on v1.1

Thanks,
Chris [MSFT]

--------------------
From: "Jay Douglas" <RE*********************************@squarei.com >
Subject: Page_Load Event Fires Twice When Sending Down a PDF
Date: Fri, 20 Feb 2004 11:53:14 -0700
Lines: 45
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <eb**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: eslick186.customer.frii.net 216.17.166.186
Path: cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!tk2msftngp13.
phx.gblXref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:211884
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

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 isfried 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 to correct
the issue or when MS is going to be able to fix this bug. The
Autoeventwireup is set to false. (I've also trited using Reponse.End() and
Response.Flush() )

Here is the code for the Page_Load event:

int docId;
ErezDoc doc;
byte[] b;

if (Request.Params["d"] != null)
{
if((docId = Convert.ToInt32(Request.Params["d"])) > 0)
{

doc = new ErezDoc(docId);

b = doc.GetData();

Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", b.Length.ToString());
Response.AddHeader("content-disposition", "inline; filename=" +
doc.DocId.ToString() + ".PDF");
Response.BinaryWrite(b);

doc.Clear();
}
}
--
Jay Douglas
Fort Collins, CO



Nov 18 '05 #2
Chris,
This is not the default page in IIS. I'm using the v1.1 framework. I
am having these issues on IIS v5.1 (XP) and v5.0.

--
Jay Douglas
Fort Collins, CO

"Chris Moore" <cm****@online.microsoft.com> wrote in message
news:H2**************@cpmsftngxa07.phx.gbl...
Hi Jay,

I've got a couple of questions for you:
What version of the Framework are you using? Also, is this page set as the default page in IIS? Third, is smartnavigavtion set to true for this page?
This combination of settings has been known to cause the page_load event to fire twice in certain circumstances on v1.1

Thanks,
Chris [MSFT]

--------------------
From: "Jay Douglas" <RE*********************************@squarei.com >
Subject: Page_Load Event Fires Twice When Sending Down a PDF
Date: Fri, 20 Feb 2004 11:53:14 -0700
Lines: 45
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <eb**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: eslick186.customer.frii.net 216.17.166.186
Path:

cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!tk2msftngp13. phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:211884X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

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 to correctthe issue or when MS is going to be able to fix this bug. The
Autoeventwireup is set to false. (I've also trited using Reponse.End() andResponse.Flush() )

Here is the code for the Page_Load event:

int docId;
ErezDoc doc;
byte[] b;

if (Request.Params["d"] != null)
{
if((docId = Convert.ToInt32(Request.Params["d"])) > 0)
{

doc = new ErezDoc(docId);

b = doc.GetData();

Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", b.Length.ToString());
Response.AddHeader("content-disposition", "inline; filename=" +
doc.DocId.ToString() + ".PDF");
Response.BinaryWrite(b);

doc.Clear();
}
}
--
Jay Douglas
Fort Collins, CO


Nov 18 '05 #3
I am encountering the exact same problem. It also occurs with Word
Documents.

I have created a simple web page that experiences the same behavior with the
following code.....

{
System.IO.FileStream FileContent;

string FileName = "Adobe1";

byte[] array;
FileContent =
System.IO.File.Open("C:\\AA_NET_Examples\\AlchemyW ebFramesTest\\" + FileName
+ ".pdf", System.IO.FileMode.Open, System.IO.FileAccess.Read);
page.Response.Clear();
page.Response.ContentType = "application/pdf";
page.Response.AddHeader("content-disposition", "inline; filename =
Adobe1.pdf");
page.Response.AddHeader("content-length",
FileContent.Length.ToString());
array = new byte[FileContent.Length];
FileContent.Read(array, 0, (int)FileContent.Length);
page.Response.BinaryWrite(array);
FileContent.Close();

page.Response.End();
}

Thanks in Advance
Rod Billett
Rodney<IhateSpam>B@IMR<IhateSpam>Gold.com
"Jay Douglas" <RE*********************************@squarei.com > wrote in
message news:ew**************@TK2MSFTNGP09.phx.gbl...
Chris,
This is not the default page in IIS. I'm using the v1.1 framework. I
am having these issues on IIS v5.1 (XP) and v5.0.

--
Jay Douglas
Fort Collins, CO

"Chris Moore" <cm****@online.microsoft.com> wrote in message
news:H2**************@cpmsftngxa07.phx.gbl...
Hi Jay,

I've got a couple of questions for you:
What version of the Framework are you using? Also, is this page set as

the
default page in IIS? Third, is smartnavigavtion set to true for this

page?

This combination of settings has been known to cause the page_load event

to
fire twice in certain circumstances on v1.1

Thanks,
Chris [MSFT]

--------------------
From: "Jay Douglas" <RE*********************************@squarei.com >
Subject: Page_Load Event Fires Twice When Sending Down a PDF
Date: Fri, 20 Feb 2004 11:53:14 -0700
Lines: 45
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <eb**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: eslick186.customer.frii.net 216.17.166.186
Path:

cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!tk2msftngp13.
phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:211884X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Hello all,
I have a asp.net page that creates a pdf on the fly and sends the pdfdown 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
seriousperformance issues. Writing the PDF to the filesystem then a redirect isnot an option. I was wondering if anybody has any input on how to

correctthe issue or when MS is going to be able to fix this bug. The
Autoeventwireup is set to false. (I've also trited using Reponse.End() andResponse.Flush() )

Here is the code for the Page_Load event:

int docId;
ErezDoc doc;
byte[] b;

if (Request.Params["d"] != null)
{
if((docId = Convert.ToInt32(Request.Params["d"])) > 0)
{

doc = new ErezDoc(docId);

b = doc.GetData();

Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", b.Length.ToString());
Response.AddHeader("content-disposition", "inline; filename=" +
doc.DocId.ToString() + ".PDF");
Response.BinaryWrite(b);

doc.Clear();
}
}
--
Jay Douglas
Fort Collins, CO



Nov 18 '05 #4
I'm having the same problem right now... Did u ever find a
solution/reason for this behaviour?

Thx
"RodBillett" <No***@NoWhere.Com> wrote in message news:<#1**************@TK2MSFTNGP09.phx.gbl>...
I am encountering the exact same problem. It also occurs with Word
Documents.

I have created a simple web page that experiences the same behavior with the
following code.....

{
System.IO.FileStream FileContent;

string FileName = "Adobe1";

byte[] array;
FileContent =
System.IO.File.Open("C:\\AA_NET_Examples\\AlchemyW ebFramesTest\\" + FileName
+ ".pdf", System.IO.FileMode.Open, System.IO.FileAccess.Read);
page.Response.Clear();
page.Response.ContentType = "application/pdf";
page.Response.AddHeader("content-disposition", "inline; filename =
Adobe1.pdf");
page.Response.AddHeader("content-length",
FileContent.Length.ToString());
array = new byte[FileContent.Length];
FileContent.Read(array, 0, (int)FileContent.Length);
page.Response.BinaryWrite(array);
FileContent.Close();

page.Response.End();
}

Thanks in Advance
Rod Billett
Rodney<IhateSpam>B@IMR<IhateSpam>Gold.com
"Jay Douglas" <RE*********************************@squarei.com > wrote in
message news:ew**************@TK2MSFTNGP09.phx.gbl...
Chris,
This is not the default page in IIS. I'm using the v1.1 framework. I
am having these issues on IIS v5.1 (XP) and v5.0.

--
Jay Douglas
Fort Collins, CO

"Chris Moore" <cm****@online.microsoft.com> wrote in message
news:H2**************@cpmsftngxa07.phx.gbl...
Hi Jay,

I've got a couple of questions for you:
What version of the Framework are you using? Also, is this page set as the default page in IIS? Third, is smartnavigavtion set to true for this page?
This combination of settings has been known to cause the page_load event to fire twice in certain circumstances on v1.1

Thanks,
Chris [MSFT]

--------------------
>From: "Jay Douglas" <RE*********************************@squarei.com >
>Subject: Page_Load Event Fires Twice When Sending Down a PDF
>Date: Fri, 20 Feb 2004 11:53:14 -0700
>Lines: 45
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>Message-ID: <eb**************@tk2msftngp13.phx.gbl>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>NNTP-Posting-Host: eslick186.customer.frii.net 216.17.166.186
>Path:

cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!tk2msftngp13.
phx.gbl
>Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:211884 >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>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 to correct >the issue or when MS is going to be able to fix this bug. The
>Autoeventwireup is set to false. (I've also trited using Reponse.End() and >Response.Flush() )
>
>Here is the code for the Page_Load event:
>
>int docId;
>ErezDoc doc;
>byte[] b;
>
>if (Request.Params["d"] != null)
>{
> if((docId = Convert.ToInt32(Request.Params["d"])) > 0)
> {
>
> doc = new ErezDoc(docId);
>
> b = doc.GetData();
>
> Response.Clear();
> Response.ContentType = "application/pdf";
> Response.AddHeader("content-length", b.Length.ToString());
> Response.AddHeader("content-disposition", "inline; filename=" +
>doc.DocId.ToString() + ".PDF");
> Response.BinaryWrite(b);
>
> doc.Clear();
> }
>}
>
>
>--
>Jay Douglas
>Fort Collins, CO
>
>
>
>
>


Nov 18 '05 #5
bump

Is this still an open issue?

This is killin me here!

Nov 19 '05 #6
Which browser? Maybe this one helps if with IE
http://support.microsoft.com/default...b;en-us;293792

--
Teemu Keiski
ASP.NET MVP, Finland

"cmay" <cm**@walshgroup.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
bump

Is this still an open issue?

This is killin me here!

Nov 19 '05 #7
It is like that, but the fix for that problem is to check the
useragent.
But in my case, the useragent is exactly the same for all requests.

Nov 19 '05 #8

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

Similar topics

0
1424
by: Gary | last post by:
When attempting to write a PDF stream to the web browser, the Page_Load event fires twice if a user has Internet Explorer configured to 'Check for newer versions of stored pages: Every visit to...
3
4876
by: Peter Row | last post by:
Hi, I have created a user control consisting of a textbox and a separate vertical scroll bar. The textbox is filled with data. However there could be lots of data so I only fill the textbox...
1
3931
by: Jon | last post by:
Hi, I've set up a new web form (new.aspx) that inherits a BasePage class. The new web form contains an override Page_Load event. In BasePage, Page_Load is declared 'virtual'. In the new web...
4
1700
by: Ed | last post by:
Has anyone seen this one? I have a situation where code in my page_load event is firing twice for mozilla firefox users. Everything is fine in IE6. I set breakpoints and verified. The second time...
14
13089
by: V. Jenks | last post by:
I'm a little rusty having not touched .NET for 6 months and I can't remember why Page_Load is happening twice in this code: private void Page_Load(object sender, System.EventArgs e) {...
3
2414
by: doobdave | last post by:
Hi all, I'm experiencing a rather strange problem: I am coding a web application using VB.net ASP.net and Visual Studio 2003. It's quite a large application, but the problem only occurs on...
4
3941
by: Seraph | last post by:
Again, I'm rather new here, so if I fail to follow any etiquette, please forgive me and let me know what I've done wrong, but I think this might interest quite a few people. One of my colleaques...
0
1922
by: pat.allan | last post by:
Hi All This seems to be a common problem here, but I've not found a solution yet to fix it for me. When I request a page through a browser, the page_load fires once. When I request the page's...
1
1825
by: =?Utf-8?B?TWlrZXkgQmFieQ==?= | last post by:
Greetings Hopefully, I can be clear and concise on this one, but I'm confused. I have a page with a ListBox <- ODS <- BusinessObject and a button. The Parameter Source is 'None'. The Default...
0
7119
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,...
0
7195
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...
1
6873
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...
0
7367
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...
0
5453
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,...
1
4889
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1400
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 ...
0
285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.