Page_Load Event Fires Twice When Sending Down a PDF

J

Jay Douglas

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();
}
}
 
C

Chris Moore

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]

--------------------
 
J

Jay Douglas

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 said:
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" <[email protected]>
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: <eb1#wK#[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: eslick186.customer.frii.net 216.17.166.186
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.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();
}
}
 
R

RodBillett

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\\AlchemyWebFramesTest\\" + 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 said:
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 said:
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" <[email protected]>
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: <eb1#wK#[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: eslick186.customer.frii.net 216.17.166.186
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.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();
}
}
 
P

Pablodio

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

Thx
RodBillett said:
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\\AlchemyWebFramesTest\\" + 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 said:
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 said:
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" <[email protected]>
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: <eb1#wK#[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: eslick186.customer.frii.net 216.17.166.186
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.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();
}
}
 
C

cmay

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.
 

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,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top