title: ASP.Net Core MVC UseExceptionHandler results in blank page
body: <p>Building an ASP.Net Core (V2) MVC Site. </p>
  
  <p>We are using API Versions for this.</p>
  
  <p>The site has controllers delivering MVC Razor Views as well as API-style Json responses.</p>
  
  <p>I am trying to use the UseExceptionHandler() method, as shown below. </p>
  
  <p>When i hit an exception in one of my actions, the action gets executed again and then a blank page shown. The browser console is free from any errors too. Finally, my error action is never hit.</p>
  
  <p>I have a custom exception filter in place for the API controllers, also shown below. I have commented this out, figuring it was interfering. This didn't resolve any issue. </p>
  
  <p>Where am I going wrong? And how can i have my custom error page hit when there is an exception.</p>
  
  <p>Exception Handler Method - This results in "/v1.0/home/error"</p>
  
  <pre><code>app.UseExceptionHandler($"/v{appSettings.Value.APIVersion}/home/error");
  </code></pre>
  
  <p>I have also tried, after reading that this is supposed to be the path to a view</p>
  
  <p><code>app.UseExceptionHandler("/error");</code></p>
  
  <p>and </p>
  
  <p><code>app.UseExceptionHandler("/views/home/error");</code></p>
  
  <p>The Error Action</p>
  
  <pre><code> [HttpGet("error")]
   public IActionResult Error()
   {
        var exception = HttpContext.Features.Get&lt;IExceptionHandlerFeature&gt;();
        ViewData["statusCode"] = HttpContext.Response.StatusCode;
        ViewData["message"] = exception.Error.Message;
        return View();
   }
  </code></pre>
  
  <p>The Exception Filter (currently commented out in the startup.cs)</p>
  
  <pre><code>public override void OnException(ExceptionContext context)
   {
         if (context.HttpContext.Request.Path.Value.Contains("/api"))
         {
               // Set the response
               context.ModelState.GroupErrorsIntoKey("ErrorArray");
               context.ModelState.AddModelError("ErrorArray", context.Exception.Message);
               context.Result = new BadRequestObjectResult(context.ModelState);
           }
   }
  </code></pre>