PRB: ASP 0156: 80004005 Header Error

Symptoms

When you view an Active Server Pages (ASP) page in a browser, the following error can occur:
Response object error 'ASP 0156 : 80004005'
Header Error
/VirtualDirectory/ASPPage.asp, line XX

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

Cause

This error occurs because the Web server uses an HTTP header to set the client browser. The Web server then tries to reset the client brower by using another HTTP header (for example, when an HTTP header sets the browser to content-type=text/html and then a redirection is issued after this). An example of this is when an ASP page is processed that contains HTML tags or any other server-side scripts before a Response.Redirect statement.

Note This also occurs if you upgraded a computer that is running Microsoft Windows NT 4.0 to Microsoft Windows Server 2003.

An example of this is when an ASP page is processed that contains HTML tags or any other server-side scripts before a Response.Redirect statement.

The following properties and methods of the Response object of ASP write HTTP headers:
Response.AddHeader
Response.CacheControl
Response.CharSet
Response.ContentType
Response.Expires
Response.ExpiresAbsolute
Response.Redirect
Response.Status

Resolution

To resolve this problem, set the HTTP Headers, such as Redirect statements or cookie information, before you send HTML output.

For example, to avoid this error with redirection, buffer or withhold the ASP page during its processing and issue the redirection after processing. There are two ways to accomplish buffering: on an application level or on a page level.

Note Ensure that the redirection is issued after all ASP scripts. If it is issued prior to ASP scripts, the ASP page redirects without processing the ASP code.

On an application level, all ASP pages within the Web application will be buffered when they are processed. To set buffering on an application level, follow these steps:
  1. In the Microsoft Management Console (MMC), locate the Web site where your Web application resides.
  2. Click to expand the Web site to display the virtual directories and Web applications.
  3. Right-click the Web application, and then click Properties.
  4. On the Virtual Directory tab, click Configuration.

    Note If the Configuration button is unavailable, the virtual directory is not a Web application. Click Create to create the virtual directory to a Web application.
  5. In the Application Configuration dialog box, on the App Options tab, click Enable buffering.
To set buffering on a page level, add code after the @LANGUAGE line on an ASP page as shown below:
<% @LANGUAGE = "VBScript" %>
<% Response.Buffer = True %>
Other ASP/Clientside scripts or HTML ...
<% Response.Redirect %>
In addition, you can use cookies to set buffering on a page level, as the following code demonstrates. This code snippet writes the cookie prior to the sending the <HTML> tag (element).
Response.Cookies("Name")=value
<HTML>
...content...
</HTML>

Status

This behavior is by design and is a restriction of the HTTP protocol.
Svojstva

ID članka: 229657 - posljednja izmjena: 14. kol 2008. - verzija: 1

Povratne informacije