title: UseExceptionHandler("/error") in Blazor WebAssembly hosted application
body: <p>I am implementing a Blazor WebAssembly hosted application, where I want to use a global exception handler in the backend project, which catches all unhandled exceptions, handles them and finally sends a Problem back to the client.</p>
  <p>The ErrorController looks as follows:</p>
  <pre><code>public class ErrorController : ControllerBase
  {
      private ErrorResponse _errorResponse = null;
  
      [Route(&quot;/error&quot;)]
      public async Task&lt;IActionResult&gt; Error()
      {
          var context = HttpContext.Features.Get&lt;IExceptionHandlerFeature&gt;();
          var exception = context.Error;
  
          var exceptionType = exception.GetType();
  
          if (exceptionType == typeof(CustomException))
          {
              var customException = (CustomException) exception;
              _errorResponse.Message = customException.Message;
              _errorResponse.StatusDescription = customException.StatusDescription;
              _errorResponse.Status = customException.StatusCode;
          }
  
  
          if (_errorResponse != null)
              await SendError();
  
          // Send Problem for fallback
          return Problem(exception.Message);
  
      }
  
      private Task SendError()
      {
          HttpContext.Response.ContentType = &quot;application/json&quot;;
          HttpContext.Response.StatusCode = _errorResponse.Status;
  
          return HttpContext.Response.WriteAsync(_errorResponse.ToString());
      }
  </code></pre>
  <p>The controller is registered as the ExceptionHandler in Startup.Configure:</p>
  <pre><code>public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
      {
          app.UseResponseCompression();
          
          if (env.IsDevelopment())
          {
              app.UseWebAssemblyDebugging();
          }
          else
          {
              app.UseHsts();
          }
  
          app.UseHttpsRedirection();
          app.UseBlazorFrameworkFiles();
          app.UseStaticFiles();
  
          // Does not work
          app.UseExceptionHandler(&quot;/error&quot;);
  
          app.UseRouting();
  
          app.UseAuthentication();
          app.UseAuthorization();
  
          app.UseEndpoints(endpoints =&gt;
          {
              endpoints.MapRazorPages();
              endpoints.MapControllers();
              endpoints.MapFallbackToFile(&quot;index.html&quot;);
          });
      }
  </code></pre>
  <p>Although I could not find any hints, that this is not supported within Blazor WebAssembly hosted projects, the ErrorController is never called when a unhandled exception occures, the Exceptions are just rethrown an the application stops.</p>
  <p>Is there a clarification which middlewares are supported inside hosted Blazor WebAssembly server projects?</p>