title: HttpModule, Response.Filter, and images not displayed
body: <p>The HttpModule works fine ("hello" is replaced with "hello world") but for some reasons images on the WebForms are not displayed when the module is added to the Web.config. When the module is removed from the Web.config, images on the WebForms are displayed.</p>
  
  <p>Does anyone know why?</p>
  
  <p>The HTML that is produced with or without the HttpModule is exactly the same!</p>
  
  <pre><code>//The HttpModule
  
  public class MyModule : IHttpModule
  {
          #region IHttpModule Members
  
          public void Dispose()
          {
              //Empty
          }
  
          public void Init(HttpApplication context)
          {
              context.BeginRequest += new EventHandler(OnBeginRequest);
              application = context;
          }
  
          #endregion
  
          void OnBeginRequest(object sender, EventArgs e)
          {
              application.Response.Filter = new MyStream(application.Response.Filter);
          }
  }
  </code></pre>
  
  <p><strong>//The filter - replace "hello" with "hello world"</strong></p>
  
  <pre><code>public class MyStream : MemoryStream
  {
          private Stream outputStream = null;
  
          public MyStream(Stream output)
          {
              outputStream = output;
          }
  
          public override void Write(byte[] buffer, int offset, int count)
          {
  
              string bufferContent = UTF8Encoding.UTF8.GetString(buffer);
              bufferContent = bufferContent.Replace("hello", "hello world");
              outputStream.Write(UTF8Encoding.UTF8.GetBytes(bufferContent), offset, UTF8Encoding.UTF8.GetByteCount(bufferContent));
  
              base.Write(buffer, offset, count);
          }
  }
  </code></pre>