title: Asynchronous HttpModule MVC
body: <p>I have a synchronous HttpModule that contains the following code.
  </p>
  
  <pre><code>    /// &lt;summary&gt;
      /// Occurs as the first event in the HTTP pipeline chain of execution 
      /// when ASP.NET responds to a request.
      /// &lt;/summary&gt;
      /// &lt;param name="sender"&gt;The source of the event.&lt;/param&gt;
      /// &lt;param name="e"&gt;An &lt;see cref="T:System.EventArgs"&gt;EventArgs&lt;/see&gt; that 
      /// contains the event data.&lt;/param&gt;
      private async void ContextBeginRequest(object sender, EventArgs e)
      {
          HttpContext context = ((HttpApplication)sender).Context;
          await this.ProcessImageAsync(context);
      }
  </code></pre>
  
  <p>When I try to run the module from an empty MVC4 application (NET 4.5) I get the following error.</p>
  
  <blockquote>
    <p>An asynchronous operation cannot be started at this time. Asynchronous
    operations may only be started within an asynchronous handler or
    module or during certain events in the Page lifecycle. If this
    exception occurred while executing a Page, ensure that the Page is
    marked &lt;%@ Page Async="true" %>.</p>
  </blockquote>
  
  <p>I'm missing something it seems but by my reading that the error shouldn't actually occur.</p>
  
  <p>I've had a dig around but I cannot seem to find anything to help, does anyone have any ideas?</p>