title: How do I execute a controller action from an HttpModule in ASP.NET MVC?
body: <p>I've got the following <code>IHttpModule</code> and I'm trying to figure out how to execute an action from a controller for a given absolute or relative URL.</p>
  
  <pre><code>public class CustomErrorHandlingModule : IHttpModule
  {
      #region Implementation of IHttpModule
  
      public void Init(HttpApplication context)
      {
          context.Error += (sender, e) =&gt; 
              OnError(new HttpContextWrapper(((HttpApplication)sender).Context));
      }
  
      public void Dispose()
      {}
  
      public void OnError(HttpContextBase context)
      {
          // Determine error resource to display, based on HttpStatus code, etc.
          // For brevity, i'll hardcode it for this SO question.
          const string errorPage = @"/Error/NotFound";
  
          // Now somehow execute the correct controller for that route.
          // Return the html response.
      }
  }
  </code></pre>
  
  <p>How can this be done?</p>