title: ASP NET MVC OnException not being called ApiController
body: <p>I am trying to intercept all exceptions, but the code is never run. I have tried putting this to <code>GlobalFilters</code>, and also putting it directly on my method.</p>
  
  <p>My Attributes:</p>
  
  <pre><code>[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
  public class HandleExceptionAttribute : HandleErrorAttribute 
  {
      private ILog log = LogManager.GetLogger(typeof(HandleExceptionAttribute));
  
      public override void OnException(ExceptionContext filterContext) 
      {
          log.Info("inside on exception"); // this never appears
      }
  }
  </code></pre>
  
  <p>My class:</p>
  
  <pre><code>public class Tester 
  {
      [HandleException]
      public void Except() 
      {
          var asd = 0;
          var qwe = 1 / asd;              
      }
  }
  </code></pre>
  
  <p>Dividing by zero give me an exception, my debugger catches it, I continue, but nothing is written into log file.</p>
  
  <p>The logger works. Other logs appear in file. Even if I disable debugging, it doesn't read the log file, so it's not debuggers fault.</p>
  
  <p>Running this on IIS Express. Windows 7.</p>
  
  <p>EDIT:</p>
  
  <p>Moved the thing to controller. Still not working</p>
  
  <pre><code>public class UserController : ApiController 
  {
      private ILog log = LogManager.GetLogger(typeof(UserController));
  
      [HandleException]
      [CheckModelForNull]
      [ValidateModelState]
      public object Post([FromBody]User user) 
      {    
          var asd = 0;
          var qwe = 1 / asd;
          return new HttpStatusCodeResult(HttpStatusCode.OK);
      }
  }
  </code></pre>