By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,302 Members | 1,788 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,302 IT Pros & Developers. It's quick & easy.

Page_Load Event Fires Twice When Sending Down a PDF

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
bump

Is this still an open issue?

This is killin me here!

Nov 19 '05 #6

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.