Help With the Response Command.

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()
 
M

mortb

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top