title: ASP.NET Core MVC (former MVC 6) Razor errors not getting caught by exception filter
body: <p>Background: ASP.NET 5 (ASP.NET Core 1.0) MVC 6 application using Dapper and the Repository Pattern</p>
  
  <p>Obviously, like with every other website/app, I'm trying to eliminate most/all of the exceptions that popup in my website.</p>
  
  <p>I implemented an <code>ExceptionFilter</code> in order to catch all unhandled exceptions like this:</p>
  
  <pre><code>public class UnhandledExceptionFilter : ActionFilterAttribute, IExceptionFilter
  {
      private readonly IErrorRepo _errorRepo;
  
      public UnhandledExceptionFilter(IErrorRepo errorRepo)
      {
          _errorRepo = errorRepo;
      }
  
      public void OnException(ExceptionContext context)
      {
          try
          {
              _errorRepo.SaveException(context.Exception);
          }
          catch { }
      }
  }
  </code></pre>
  
  <p>This works great when the error comes from <code>C#</code> code. But I've purposely put in errors in my razor views (cshtml files) and those are NOT getting caught by this filter.</p>
  
  <p>Is there an additional attribute/interface that I need to inherit in order to catch razor exceptions?</p>
  
  <p>UPDATE:</p>
  
  <p>Here's where the filter attribute is specified, in the startup.cs file in the ConfigureServices method.</p>
  
  <pre><code>    services.AddMvc(options =&gt;
      {
          options.Filters.Add(new UnhandledExceptionFilter(new ErrorRepo(Configuration)));
      });
  </code></pre>