title: Globally applied custom exception filter is not triggered when error is thrown by a method called in the constructor of my base controller
body: <p>I  have this custom exception filter:</p>
  
  <pre><code>public class CustomExceptionFilter : IExceptionFilter
  {
      public void OnException(ExceptionContext filterContext)
      {
          try
          {
              if (filterContext == null) return;
  
              // Log error details to the DB
          }
          catch
          {
              // Intentional empty catch
          }
      }
  }
  </code></pre>
  
  <p>Which is applied globally in RegisterGlobalFilters (which is called from Application_Start):</p>
  
  <pre><code>public static void RegisterGlobalFilters(GlobalFilterCollection filters)
  {
      filters.Add(new CustomExceptionFilter());
      filters.Add(new HandleErrorAttribute());
  }
  </code></pre>
  
  <p>I then have a protected constructor on my BaseController which calls this method:</p>
  
  <pre><code>public Site GetSiteByUrl(string host)
  {
      var urls = _repo.Urls.Where(x =&gt; x.Host == host);
  
      if (urls == null || !urls.Any())
          throw new MultiTenancyException(String.Format("No URL record exists for request. Host = \"{0}\"", host));
  
      if (urls.Count() &gt; 1)
          throw new MultiTenancyException(String.Format("Multiple URL records exist for request. Host = \"{0}\"",
              host));
  
      var url = urls.Single();
      var site = _repo.Sites.Single(x =&gt; x.Id == url.SiteId);
  
      if (!url.Enabled)
          throw new MultiTenancyException(
              String.Format("URL record found for request, but is not Enabled. Host = \"{0}\", Site = \"{1}\"",
                  host, site.Name));
  
      return site;
  }
  </code></pre>
  
  <p>When any of the MultiTenancyExceptions in this method are thrown the OnException event of my CustomExceptionFilter is not triggered.</p>
  
  <p>I've tried:</p>
  
  <ul>
  <li>Using a basic Exception rather than my custom MultiTenancyException.</li>
  <li>Applying the CustomExceptionFilter as an attribute on the controller rather than globally via RegisterGlobalFilters.</li>
  </ul>
  
  <p>Both to no avail. Looking back through the logs of exceptions that have been caught by the CustomExceptionFilter the only logged errors seem to by system exceptions (NullReference, ArgumentOutOfRange etc.) which may be relevant or may simply be a coincidence.</p>
  
  <p>I've been Googling around for about 30 minutes and am starting to bang my head against the wall at this point, so I'm looking for any sensible ideas.</p>
  
  <p>Thanks.</p>