title: ASP.net MVC - Custom HandleError Filter - Specify View based on Exception Type
body: <p>I am inheriting the <code>HandleErrorAttribute</code> in my MVC application so I can log the error:</p>
  
  <pre><code>public class HandleAndLogErrorAttribute : HandleErrorAttribute
  {
      public override void OnException(ExceptionContext filterContext)
      {
          base.OnException(filterContext);
  
          if( filterContext.Exception != null )
          {
              // log here
          }
      }
  }
  </code></pre>
  
  <p>I'm adding this as a global filter:</p>
  
  <pre><code>public static void RegisterGlobalFilters(GlobalFilterCollection filters)
  {
      filters.Add(new HandleAndLogErrorAttribute());
  }
  </code></pre>
  
  <p>Is it possible to specify a custom view for specific exception types as well? For example:</p>
  
  <pre><code>if( filterContext.Exception is DivideByZeroException )
  {
      // how do i specify that the view should be DivideByZero?
  }
  </code></pre>