Page_Load Event Fires Twice When Sending Down a PDF

Discussion in 'ASP .Net' started by Jay Douglas, Feb 20, 2004.

  1. Jay Douglas

    Jay Douglas Guest

    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
     
    Jay Douglas, Feb 20, 2004
    #1
    1. Advertising

  2. Jay Douglas

    Chris Moore Guest

    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" <>
    >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#>
    >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();
    > }
    >}
    >
    >
    >--
    >Jay Douglas
    >Fort Collins, CO
    >
    >
    >
    >
    >
     
    Chris Moore, Feb 20, 2004
    #2
    1. Advertising

  3. Jay Douglas

    Jay Douglas Guest

    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" <> wrote in message
    news:H2epml$...
    > 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" <>
    > >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#>
    > >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();
    > > }
    > >}
    > >
    > >
    > >--
    > >Jay Douglas
    > >Fort Collins, CO
    > >
    > >
    > >
    > >
    > >

    >
     
    Jay Douglas, Feb 22, 2004
    #3
  4. Jay Douglas

    RodBillett Guest

    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" <> wrote in
    message news:ewurPHW#...
    > 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" <> wrote in message
    > news:H2epml$...
    > > 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" <>
    > > >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#>
    > > >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();
    > > > }
    > > >}
    > > >
    > > >
    > > >--
    > > >Jay Douglas
    > > >Fort Collins, CO
    > > >
    > > >
    > > >
    > > >
    > > >

    > >

    >
    >
     
    RodBillett, Feb 23, 2004
    #4
  5. Jay Douglas

    Pablodio Guest

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

    Thx
    "RodBillett" <> wrote in message news:<#1MOMyk#>...
    > 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" <> wrote in
    > message news:ewurPHW#...
    > > 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" <> wrote in message
    > > news:H2epml$...
    > > > 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" <>
    > > > >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#>
    > > > >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();
    > > > > }
    > > > >}
    > > > >
    > > > >
    > > > >--
    > > > >Jay Douglas
    > > > >Fort Collins, CO
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > >

    > >
    > >
     
    Pablodio, Mar 1, 2004
    #5
  6. Jay Douglas

    cmay Guest

    bump

    Is this still an open issue?

    This is killin me here!
     
    cmay, Jan 6, 2005
    #6
  7. Jay Douglas

    Teemu Keiski Guest

    Teemu Keiski, Jan 7, 2005
    #7
  8. Jay Douglas

    cmay Guest

    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.
     
    cmay, Jan 10, 2005
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. H Branyan

    Page_Load fires twice

    H Branyan, Oct 22, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    683
    H Branyan
    Oct 22, 2003
  2. Jon
    Replies:
    1
    Views:
    11,382
    George Ter-Saakov
    Jan 13, 2004
  3. =?Utf-8?B?RWQ=?=

    Page_Load fires twice with Mozilla

    =?Utf-8?B?RWQ=?=, Nov 20, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    4,475
    shailpatel83
    Apr 2, 2010
  4. doobdave
    Replies:
    3
    Views:
    4,095
    Jeff Evans
    Dec 17, 2004
  5. =?Utf-8?B?RXJpayBKZW5zZW4=?=

    CodeBehind But Not Postback - Page_Load fires twice

    =?Utf-8?B?RXJpayBKZW5zZW4=?=, Jul 19, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    3,321
    =?Utf-8?B?RXJpayBKZW5zZW4=?=
    Jul 21, 2005
Loading...

Share This Page