title: IHttpModule Mangling Classic ASP Form Data
body: <p>I have a classic ASP page that I want to wrap up in some logging using an IHTTPModule.</p>
  
  <p>My problem is that if my module accesses any form vars before the page is executed, my ASP page returns an error '80004005' as soon as the first Request.Form is accessed.</p>
  
  <p>If I hook my module into events that occur after the asp page has processed, then then httpApplication.Context.Request.Form collection is empty.</p>
  
  <p>Sample module:</p>
  
  <pre><code>using System;
  using System.Web;
  
  namespace FormPostTest
  {
  public class MyModule1 : IHttpModule
  {
  
      public void Dispose()
      {
          //clean-up code here.
      }
  
  
      public void Init(HttpApplication context)
      {
          /* 
           With this line (begin request) I get
            error '80004005'
                  /index.asp, line 11 as soon as Request.Form is accessed from the ASP page, however the form collection
           is populated.
  
           */
          context.BeginRequest += context_GetFormParams;
  
          /*
           * The line causes for form collection to be empty
           * */
          // context.LogRequest += new EventHandler(context_GetFormParams);
      }
  
  
      private void context_GetFormParams(object sender, EventArgs e)
      {
          HttpApplication httpApplication = (HttpApplication) sender;
          Console.WriteLine(httpApplication.Context.Request.Form.Get("MyFormParam"));
      }
  
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Here is my classic ASP page.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;&lt;/head&gt;
  &lt;body&gt;
      &lt;form method="post" action="index.asp"&gt;
          &lt;input name="MyFormParam" value="Hello" /&gt;
          &lt;input type="submit" /&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;%=Request.form("MyFormParam")%&gt;
  </code></pre>