Skip to content

Commit 29a868d

Browse files
authored
Document ASP.NET Core 10.0 breaking change: Exception diagnostics suppression (#47900)
1 parent 5cf4631 commit 29a868d

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

docs/core/compatibility/10.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af
2020
| Title | Type of change | Introduced version |
2121
|-------|---------------------|--------------------|
2222
| [Deprecation of WithOpenApi extension method](aspnet-core/10/withopenapi-deprecated.md) | Source incompatible | Preview 7 |
23+
| [Exception diagnostics suppressed when TryHandleAsync returns true](aspnet-core/10/exception-handler-diagnostics-suppressed.md) | Behavioral change | Preview 7 |
2324
| [IActionContextAccessor and ActionContextAccessor are obsolete](aspnet-core/10/iactioncontextaccessor-obsolete.md) | Source incompatible/behavioral change | Preview 7 |
2425
| [IncludeOpenAPIAnalyzers property and MVC API analyzers are deprecated](aspnet-core/10/openapi-analyzers-deprecated.md) | Source incompatible | Preview 7 |
2526
| [Microsoft.Extensions.ApiDescription.Client package deprecated](aspnet-core/10/apidescription-client-deprecated.md) | Source incompatible | Preview 7 |
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: "Breaking change: Exception diagnostics are suppressed when IExceptionHandler.TryHandleAsync returns true"
3+
description: Learn about the breaking change in ASP.NET Core 10 where exception diagnostics are no longer recorded when IExceptionHandler.TryHandleAsync returns true.
4+
ms.date: 08/08/2025
5+
---
6+
7+
# Exception diagnostics are suppressed when IExceptionHandler.TryHandleAsync returns true
8+
9+
The ASP.NET Core exception handler middleware no longer records diagnostics for exceptions handled by <xref:Microsoft.AspNetCore.Diagnostics.IExceptionHandler> by default.
10+
11+
## Version introduced
12+
13+
.NET 10 Preview 7
14+
15+
## Previous behavior
16+
17+
Previously, the exception handler middleware recorded diagnostics about exceptions handled by <xref:Microsoft.AspNetCore.Diagnostics.IExceptionHandler>.
18+
19+
The exception diagnostics are:
20+
21+
- Logging `UnhandledException` to <xref:Microsoft.Extensions.Logging.ILogger>.
22+
- Writing the `Microsoft.AspNetCore.Diagnostics.HandledException` event to <xref:Microsoft.Extensions.Logging.EventSource>.
23+
- Adding the `error.type` tag to the `http.server.request.duration` metric.
24+
25+
## New behavior
26+
27+
Starting in .NET 10, if <xref:Microsoft.AspNetCore.Diagnostics.IExceptionHandler.TryHandleAsync%2A?displayProperty=nameWithType> returns `true`, then exception diagnostics are no longer recorded by default.
28+
29+
## Type of breaking change
30+
31+
This change is a [behavioral change](../../categories.md#behavioral-change).
32+
33+
## Reason for change
34+
35+
ASP.NET Core users have given feedback that the previous behavior was undesirable. Their <xref:Microsoft.AspNetCore.Diagnostics.IExceptionHandler> implementation reported that the exception was handled, but the error handling middleware still recorded the error in the app's telemetry.
36+
37+
ASP.NET Core now follows the behavior expected by users by suppressing diagnostics when <xref:Microsoft.AspNetCore.Diagnostics.IExceptionHandler> handles the exception. Configuration options are also available to customize exception diagnostics behavior if needed.
38+
39+
## Recommended action
40+
41+
If you want handled exceptions to continue to record telemetry, you can use the new `ExceptionHandlerOptions.SuppressDiagnosticsCallback` option:
42+
43+
```csharp
44+
app.UseExceptionHandler(new ExceptionHandlerOptions
45+
{
46+
SuppressDiagnosticsCallback = context => false;
47+
});
48+
```
49+
50+
The `context` passed to the callback includes information about the exception, the request, and whether the exception was handled. The callback returns `false` to indicate that diagnostics shouldn't be suppressed, thus restoring the previous behavior.
51+
52+
## Affected APIs
53+
54+
- <xref:Microsoft.AspNetCore.Builder.ExceptionHandlerExtensions.UseExceptionHandler%2A?displayProperty=fullName>
55+
- <xref:Microsoft.AspNetCore.Diagnostics.IExceptionHandler?displayProperty=fullName>

docs/core/compatibility/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ items:
1212
items:
1313
- name: Deprecation of WithOpenApi extension method
1414
href: aspnet-core/10/withopenapi-deprecated.md
15+
- name: Exception diagnostics suppressed when TryHandleAsync returns true
16+
href: aspnet-core/10/exception-handler-diagnostics-suppressed.md
1517
- name: IActionContextAccessor and ActionContextAccessor are obsolete
1618
href: aspnet-core/10/iactioncontextaccessor-obsolete.md
1719
- name: IncludeOpenAPIAnalyzers property and MVC API analyzers are deprecated

0 commit comments

Comments
 (0)