PDA

View Full Version : Header Error


bonnie
06-19-03, 06:05 AM
Response object error 'ASP 0156 : 80004005'

Header Error

The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.

What can I do??

:(

Tesco
06-19-03, 06:18 AM
From, that, I think your trying to send some kind of file (excel, pdf) through HTTP? Thus, you doing http:// at the beginning of the link, and adding a HTTP header, which is the wrong thing to do.

I think, there are some other headers you could try but, I don't them - try searching google - or maybe someone here can tell us about the other headers available.

Shane
06-19-03, 10:27 AM
Also, are you trying to modify cookies after output from the page has already been sent?

Stealth
06-19-03, 11:32 AM
The best thing to do is test your page after everything you add so you can pinpoint any errors

bonnie
06-20-03, 03:16 AM
I think the problem is the page can not redirect the file(excel,pdf). Say for example, it can check the record exists or not. if the record exist. then open the related file.

<%
While Not rs.EOF
For i=0 to rs.Fields.Count-1
Response.Redirect rs.Fields(3)
Next
rs.MoveNext
Wend
Response.Write "<CENTER>"
Response.Write "Record not found !!"
Response.Write "</CENTER>"
%>

the error is in the red line. The file type is OLE Object.

Stealth
06-20-03, 01:07 PM
ah, i dont think its possible to stream data in that way but ive never tried so im not sure. Possibly try:



<%
While Not rs.EOF
For i=0 to rs.Fields.Count-1
Response.Clear
Response.ContentType="application/pdf"
Response.AddHeader "content- disposition", "attachment;filename=some.pdf"
Response.BinaryWrite rs.Fields(3)
Next
rs.MoveNext
Wend
Response.Write "<CENTER>"
Response.Write "Record not found !!"
Response.Write "</CENTER>"
%>

Gurrutello
06-20-03, 08:57 PM
hello
this is a commmon redirection problem
be sure to put all your asp main code before any html tags

if not try
server.transfer"your_url.asp"' if your server aloud you

saludos

bonnie
06-22-03, 08:01 AM
I will try to add it! Thanks!!

But I want to confirm that "response.redirect" supports OLE Object or not??It only supports "URL"????In my ASP Page, the OLE Object is called. :confused:

bonnie
06-23-03, 03:28 AM
I want to know something about "response.binarywrite". How can I perform an OLE object with it? Since I am confused on "response.redirect" and "response.binarywrite":( :confused:

Shane
06-23-03, 02:45 PM
response.redirect - uses the browser to redirect the user to a specific file
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iisref/htm/ref_vbom_resomre.asp

response.binarywrite - writes binary data to the http output.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iisref/htm/ref_vbom_resombw.asp

In your example, you are trying to redirect the user to an OLE object. The OLE object is binary. You are trying to redirect the user to a specific URL that contains binary data. It just won't work that way.

bonnie
06-23-03, 10:12 PM
So in my example, response.binarywrite is used.

After I do some changing, the OLE object can be displayed as a HTML format, not PDF, so the contents can't be displayed correctly, there is some unusual words. After I add the following code:

Response.ContentType="application/pdf"
Response.AddHeader "content- disposition", "attachment;filename=some.pdf"

It can load the PDF reader, not the OLE Object and the error message is occurred "File does not begin with '%PDF',

So what's wrong with it??:confused: :(

bonnie
06-25-03, 10:06 PM
Some reference said if you want to open a PDF file, you need to add something in the server or do some setting in each user's PC. But I don't know that is correct or not.

I need your help~~~~~:(