Microsoft KB Archive/812686

= FIX: When You Call the Response.ClearHeaders Method in a Custom HTTPmodule, Extra Characters Are Appended to the Output =

Article ID: 812686

Article Last Modified on 9/27/2005

-

APPLIES TO


 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Academic Edition
 * Microsoft ASP.NET 1.1

-



SYMPTOMS
When you call the Response.ClearHeaders method in a custom HTTPModule that is registered with PreSendRequestHeaders, extra characters are returned. This problem occurs only on the first request or the first time that you make this call after you compile the application.



CAUSE
For the first request of a page, the compiler tries to do a batch compile and takes a different code path in the Response.Flush method. Later in the code, when you try to add chunkprefix and chunksuffix characters, they appear as extra characters in the output.



How to Obtain the Hotfix
This issue is fixed in the June 2003 ASP.NET Hotfix Package 1.1. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

821156 INFO: ASP.NET 1.1 June 2003 Hotfix Rollup Package

You cannot obtain this fix individually. You must install the rollup.

Note When you request this hotfix, you receive the rollup.

The English version of this hotfix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.               Date         Time   Version       Size       File name ---          07-Jun-2003  00:44  1.1.4322.910    253,952  Aspnet_isapi.dll 07-Jun-2003 00:44  1.1.4322.910     20,480  Aspnet_regiis.exe 07-Jun-2003 00:44  1.1.4322.910     32,768  Aspnet_wp.exe 15-May-2003 23:49                   33,522  Installpersistsqlstate.sql 15-May-2003 23:49                   34,150  Installsqlstate.sql 07-Jun-2003 12:52  1.1.4322.910  1,216,512  System.dll 07-Jun-2003 00:39                   14,472  Webuivalidation.js           07-Jun-2003  12:52  1.1.4322.910  1,249,280  System.Web.dll



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
  Save the following code as  Stripheader.cs , and then compile this application to  Test.dll : using System.Web ; using System; using System.IO;

namespace failed {   ///     /// Summary description for the stripheader. ///    public class stripheader: IHttpModule {       private MyEventHandler _eventHandler = null;

public stripheader {           //            // TODO: Add constructor logic here. //       }        public void Init (HttpApplication app) {           app.PreSendRequestHeaders  += new EventHandler (onPreSend); }

public void Dispose{} public delegate void MyEventHandler(Object s, EventArgs e); public event MyEventHandler MyEvent {           add { _eventHandler += value; } remove { _eventHandler -= value; } }

public void onPreSend(Object s, EventArgs e)       { HttpApplication app = s as HttpApplication; app.Context.Response.ClearHeaders;

if(_eventHandler!=null) _eventHandler(this, null); }   } }   Use the following code to create a Test.aspx page: <%@ Page %> <% Response.Write (&quot;Hello World&quot;); %>   Add a default Web.config file, and then add the following section just before the end  tag:    </li> Copy the files that you created in steps 1, 2, and 3 to a virtual directory (vdir). Create a bin folder in this virtual directory, and then copy the Test.dll file to the bin folder.</li> View the Test.aspx page in your browser.

The expected text output is &quot;Hello World&quot;. However, the result is &quot;b Hello World 0 &quot;.</li></ol>

After the page has been compiled one time, it returns the correct output for all later requests. To reproduce the behavior again, modify the Web.config file, re-save the file, and then view the Test.aspx page again.

Keywords: kbbug kbfix kbqfe kbhttpmodule kbnetframe100presp3fix kbhotfixserver KB812686

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.