-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Open
Labels
DocsThis issue tracks updating documentationThis issue tracks updating documentationarea-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresfeature-diagnosticsDiagnostic middleware and pages (except EF diagnostics)Diagnostic middleware and pages (except EF diagnostics)
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Program.cs:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddExceptionHandler<GlobalExceptionHandler>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
else
{
app.UseDeveloperExceptionPage();
}
...
app.Run();
GlobalExceptionHandler.cs:
public class GlobalExceptionHandler : IExceptionHandler
{
public async ValueTask<bool> TryHandleAsync(HttpContext httpContext, Exception exception, CancellationToken cancellationToken)
{
...
return false;
}
}
As stated within the documentation , registered exception handlers are triggered when using either UseExceptionHandler() or UseDeveloperExceptionPage().
When in production (UseExceptionHander()) the GlobalExceptionHandler is triggered successfully, while in development (UseDeveloperExceptionPage()) the GlobalExceptionHandler is NOT triggered.
.NET Version
8
KennethHoff and refractalize
Metadata
Metadata
Assignees
Labels
DocsThis issue tracks updating documentationThis issue tracks updating documentationarea-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresfeature-diagnosticsDiagnostic middleware and pages (except EF diagnostics)Diagnostic middleware and pages (except EF diagnostics)