title: UseExceptionHandler does not handle all exceptions
body: <p>My application uses the recommended exception handling in ASP.NET Core:</p>
  <pre class="lang-cs prettyprint-override"><code>            if (_webHostEnvironment.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseExceptionHandler(&quot;/error/500&quot;);
                  app.UseStatusCodePagesWithReExecute(&quot;/error/{0}&quot;);
  
                  app.UseHsts();
              }
  </code></pre>
  <p>I have discovered that apparently exceptions in my Custom Cookie Validation Handler are not handled by the exception handler mechanism:</p>
  <pre class="lang-cs prettyprint-override"><code>   public class MyCustomCookieRequestValidationHandler : CookieAuthenticationEvents
      {
          public override Task ValidatePrincipal(CookieValidatePrincipalContext context)
          {
              throw new Exception()
          }
  </code></pre>
  <p>Why does the Exception Handler not process this exception?
  How can I still display an error page for cases like this?</p>
  <p>edit: as requested the full more or less default config file</p>
  <pre class="lang-cs prettyprint-override"><code>    public class MyStartup
      {
          private readonly IWebHostEnvironment _webHostEnvironment;
  
          public MyStartup(IWebHostEnvironment webHostEnvironment, IConfiguration configuration)
          {
              _webHostEnvironment = webHostEnvironment;
              Configuration = configuration;
          }
  
          public IConfiguration Configuration { get; }
  
          public void ConfigureServices(IServiceCollection services)
          {
              // ...
              // default registrations like options here
              // ...
  
              services.AddAuthentication(options =&gt;
              {
                  options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
              });
  
              services
                  .ConfigureApplicationCookie(options =&gt;
                  {
                      // cookie settings
                      options.Events = new MyCustomCookieRequestValidationHandler();
                  });
  
              services
                  .AddScoped&lt;MyCustomCookieRequestValidationHandler&gt;();
  
             // ...
             // mvc registrations
             // ...
          }
  
          public void Configure(IApplicationBuilder app)
          {
              if (_webHostEnvironment.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseForwardedHeaders(
                      new ForwardedHeadersOptions
                      {
                          ForwardedHeaders = ForwardedHeaders.XForwardedFor,
                          ForwardLimit = 1
                      }
                  );
  
                  app.UseExceptionHandler(&quot;/error/500&quot;);
                  app.UseStatusCodePagesWithReExecute(&quot;/error/{0}&quot;);
  
                  app.UseHsts();
              }
  
              app.UseHttpsRedirection();
  
              app.UseAuthentication();
  
              app.UseResponseCaching();
              app.UseStaticFiles();
  
              app.UseCookiePolicy();
              app.UseRouting();
  
              app.UseAuthorization();
  
              app.UseEndpoints(endpoints =&gt;
              {
                  endpoints.MapControllers();
              });
          }
      }
  </code></pre>