title: Application_Error event in global.asax not firing
body: <p>I'm having an issue where the <code>Application_Error</code> event does not seem to fire when I explicitly throw a page-level exception. </p>
  
  <p>My Global.asax.cs file is as follow:</p>
  
  <pre><code>public class WebApiApplication : System.Web.HttpApplication
  {
      protected void Application_Start()
      {
              AreaRegistration.RegisterAllAreas();
              WebApiConfig.Register(GlobalConfiguration.Configuration);
              FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
              RouteConfig.RegisterRoutes(RouteTable.Routes);
              BundleConfig.RegisterBundles(BundleTable.Bundles);
              CustomExceptionClass.BootstrapEnterpriseLibrary();  
      }
  
      // Event handler that passes all exceptions not in a catch statement 
      // to the handler
  
      protected void Application_Error(object sender, EventArgs e)
      {
          Exception ex = Server.GetLastError();
          CustomExceptionClass.HandleException(ex);
          Server.ClearError();
      }
  }
  
  public class ExceptionPublisherExceptionFilter : IExceptionFilter
  {
      public void OnException(ExceptionContext exceptionContext)
      {
          var exception = exceptionContext.Exception;
          CustomExceptionClass.HandleException(exception);
      }
  }
  
  public class ErrorHandler : IErrorHandler
  {
      public void ProvideFault(Exception error, MessageVersion version, 
          ref Message fault)
      {
      }
  
      public bool HandleError(Exception error)
      {
          CustomExceptionClass.HandleException(error);
          return true;
      }
  }
  </code></pre>
  
  <p>My web.config file has <code>&lt;customErrors mode="Off"&gt;</code>.</p>
  
  <p>My filterconfig looks like the following:</p>
  
  <pre><code>public static void RegisterGlobalFilters(GlobalFilterCollection filters)
  {
      filters.Add(new ExceptionPublisherExceptionFilter());
      //filters.Add(new HandleErrorAttribute());
  }
  </code></pre>
  
  <p>I have tried the following fixes:</p>
  
  <ul>
  <li>Change <code>customErrors</code> to on or off</li>
  <li>Implement a new filter and add it to filterconfig</li>
  </ul>
  
  <p>Whenever I throw an exception in VS, I try to step into it, but it just keeps on running. Does anyone know why <code>Application_Error</code> isn't being fired?</p>
  
  <p><strong>Edit</strong>: It looks like the scope affects whether <code>Application_Error</code> gets called. So the question is really, why <code>Application_Error</code> isn't being called at the page-level.</p>