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