Response object error 'ASP 0156 : 80004005
/index.asp, line 22
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.
First, what causes this error? It is exactly what is being said. You have already written HTTP headers - such as the HTML or HEAD or BODY commands. You are now trying to do something else - probably the response.redirect command. You can't go off to a new page in the middle of writing an old page.
The first most likely situation is that you really did write something out and then try to response.redirect. If you want to go to a new page, do your decision process BEFORE you start writing anything to the screen. You can't just leap half way through drawing a page. Do your processing, decide if you need to go elsewhere, and go there if you have to. If not, draw the page you are on currently. You can learn more about Using Response.Redirect to Change Pages
The second most common reason for this happening is that you were fooling with the buttons in IIS. If you go into Home Directory - Configuration - App Options, there is a checkbox called "Enable Buffering". This by default should be ON. When this is on, it means your ASP process stores up what it is working on until it reaches the end, and then sends the full page off to the user. It's the efficient way of handling ASP.
However, if you turn that checkbox OFF, you cannot just call a response.redirect command to leap to a new page. You have to start manually dealing with buffering issues. If you really want to get into this mess, be sure to read up on How Buffering Works in ASP.
The simple solution is:
* Always leave the Enable Buffering checkbox to ON
* Always use response.redirect BEFORE you write out ANY HTML.
|Introduction to ASP Ebook|
Download this ebook to get everything you need to know about learning ASP - from a step by step tutorial to function lists, sample code, common errors and solutions, and much more! 101 pages.