469,920 Members | 2,154 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,920 developers. It's quick & easy.

Page_Load event fires twice when streaming a PDF.

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 the page'. This is causing me
tremendous grief. Here's an abstract of code to prove the
problem. New FirstReport() is a blank report. Can
someone please tell me how to stop this behaviour?

Thanks Greatly

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm0.aspx.vb" Inherits="MyReport.WebForm0"%

Imports System.IO
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Web
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.CrystalReports.Engine

Public Class WebForm0 : Inherits System.Web.UI.Page

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load

Dim myRep As
CrystalDecisions.CrystalReports.Engine.ReportClass = New
FirstReport()

Dim exp As New ExportOptions()
Dim req As New ExportRequestContext()

'stream report to pdf without writing a file
to disk
exp.ExportFormatType =
ExportFormatType.PortableDocFormat
exp.FormatOptions = New PdfRtfWordFormatOptions
()
req.ExportInfo = exp
Dim st As Stream =
myRep.FormatEngine.ExportToStream(req)

Dim buffer(st.Length) As Byte
st.Read(buffer, 0, CInt(st.Length))

Response.ClearHeaders()
Response.ClearContent()
Response.Clear()
Response.ContentType = "application/pdf"
Response.BinaryWrite(buffer)
Response.End()

End Sub

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private
Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the
Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

End Class
Jul 21 '05 #1
0 1236

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Jay Douglas | last post: by
4 posts views Thread by Ed | last post: by
14 posts views Thread by V. Jenks | last post: by
3 posts views Thread by doobdave | last post: by
4 posts views Thread by Seraph | last post: by
reply views Thread by pat.allan | last post: by
1 post views Thread by =?Utf-8?B?TWlrZXkgQmFieQ==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.