Help With the Response Command.

  • Thread starter Thread starter Ric Pullen
  • Start date Start date
R

Ric Pullen

I'm using Crystal reports to display a page in PDF format now this works but
can take some time. I found a good example of how to dislpay a dynamic
"loading....." whilst the page loads. Unfortunately the two do not seem to
be compatible as it says
Server cannot clear headers after HTTP headers have been sent.
This is really down to my lack of understanding how web pages are processed,
if the answer is simple can you please let me know as it is quite a useful
script. Many Thanks

Now the example code of the "loading...." can be found here
http://www.kbalerts.com/feedback_837375.aspx

My source contains the following which is a procedure fired of in a "not is
postback" event.

Fname = Page.MapPath("rptTemp") & "\" & Session.SessionID.ToString & ".pdf"

crDiskFileDestinationOptions = New DiskFileDestinationOptions()

crDiskFileDestinationOptions.DiskFileName = Fname

crExportOptions = crReportDocument.ExportOptions

With crExportOptions

..DestinationOptions = crDiskFileDestinationOptions

..ExportDestinationType = ExportDestinationType.DiskFile

..ExportFormatType = ExportFormatType.PortableDocFormat

End With

crReportDocument.Export()

' The following code writes the pdf file

' to the Clients browser.

Response.ClearContent()

Response.ClearHeaders() <------------------Error Occurs here

Response.ContentType = "application/pdf"

Response.WriteFile(Fname)

Response.Flush()

Response.Close()
 
You cannot output *anything* to the browser and then clear the respone as
the the header of the response already has been sent.
The content type you set on the repsonse is part of the head which is the
first thing that the server sends to the browser, this can't be changed
later on as a page has one content type only.

Are you trying to first write this "waiting..." client script and then clear
the response?

/mortb
 
Back
Top