Skip to content

Commit 0b76a4e

Browse files
Document Exception Handler Middleware breaking change (#20542)
* Document Exception Handler Middleware breaking change * Add link to discussion issue * Update includes/core-changes/aspnetcore/5.0/middleware-exception-handler-throws-original-exception.md Co-authored-by: Youssef Victor <31348972+Youssef1313@users.noreply.github.com> Co-authored-by: Youssef Victor <31348972+Youssef1313@users.noreply.github.com>
1 parent 67c660f commit 0b76a4e

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

docs/core/compatibility/3.1-5.0.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Breaking changes, version 3.1 to 5.0
33
description: Lists the breaking changes from version 3.1 to version 5.0 of .NET, ASP.NET Core, and EF Core.
4-
ms.date: 09/02/2020
4+
ms.date: 09/09/2020
55
---
66
# Breaking changes for migration from version 3.1 to 5.0
77

@@ -26,6 +26,7 @@ If you're migrating from version 3.1 of .NET Core, ASP.NET Core, or EF Core to v
2626
- [Localization: Obsolete constructor removed in request localization middleware](#localization-obsolete-constructor-removed-in-request-localization-middleware)
2727
- [Localization: ResourceManagerWithCultureStringLocalizer class and WithCulture interface member removed](#localization-resourcemanagerwithculturestringlocalizer-class-and-withculture-interface-member-removed)
2828
- [Middleware: Database error page marked as obsolete](#middleware-database-error-page-marked-as-obsolete)
29+
- [Middleware: Exception Handler Middleware throws original exception if handler not found](#middleware-exception-handler-middleware-throws-original-exception-if-handler-not-found)
2930
- [Security: Cookie name encoding removed](#security-cookie-name-encoding-removed)
3031
- [Security: IdentityModel NuGet package versions updated](#security-identitymodel-nuget-package-versions-updated)
3132
- [SignalR: MessagePack Hub Protocol moved to MessagePack 2.x package](#signalr-messagepack-hub-protocol-moved-to-messagepack-2x-package)
@@ -101,6 +102,10 @@ If you're migrating from version 3.1 of .NET Core, ASP.NET Core, or EF Core to v
101102

102103
***
103104

105+
[!INCLUDE[Middleware: Exception Handler Middleware throws original exception if handler not found](~/includes/core-changes/aspnetcore/5.0/middleware-exception-handler-throws-original-exception.md)]
106+
107+
***
108+
104109
[!INCLUDE[Security: Cookie name encoding removed](~/includes/core-changes/aspnetcore/5.0/security-cookie-name-encoding-removed.md)]
105110

106111
***

docs/core/compatibility/aspnetcore.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: ASP.NET Core breaking changes
33
titleSuffix: ""
44
description: Lists the breaking changes in ASP.NET Core.
5-
ms.date: 08/25/2020
5+
ms.date: 09/09/2020
66
author: scottaddie
77
ms.author: scaddie
88
---
@@ -70,6 +70,7 @@ The following breaking changes in ASP.NET Core 3.0, 3.1, and 5.0 are documented
7070
- [Localization: ResourceManagerWithCultureStringLocalizer class and WithCulture interface member removed](#localization-resourcemanagerwithculturestringlocalizer-class-and-withculture-interface-member-removed)
7171
- [Logging: DebugLogger class made internal](#logging-debuglogger-class-made-internal)
7272
- [Middleware: Database error page marked as obsolete](#middleware-database-error-page-marked-as-obsolete)
73+
- [Middleware: Exception Handler Middleware throws original exception if handler not found](#middleware-exception-handler-middleware-throws-original-exception-if-handler-not-found)
7374
- [MVC: Controller action Async suffix removed](#mvc-async-suffix-trimmed-from-controller-action-names)
7475
- [MVC: JsonResult moved to Microsoft.AspNetCore.Mvc.Core](#mvc-jsonresult-moved-to-microsoftaspnetcoremvccore)
7576
- [MVC: Precompilation tool deprecated](#mvc-precompilation-tool-deprecated)
@@ -168,6 +169,10 @@ The following breaking changes in ASP.NET Core 3.0, 3.1, and 5.0 are documented
168169

169170
***
170171

172+
[!INCLUDE[Middleware: Exception Handler Middleware throws original exception if handler not found](~/includes/core-changes/aspnetcore/5.0/middleware-exception-handler-throws-original-exception.md)]
173+
174+
***
175+
171176
[!INCLUDE[Security: Cookie name encoding removed](~/includes/core-changes/aspnetcore/5.0/security-cookie-name-encoding-removed.md)]
172177

173178
***
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
### Middleware: Exception Handler Middleware throws original exception if handler not found
2+
3+
Before ASP.NET Core 5.0, the [Exception Handler Middleware](xref:Microsoft.AspNetCore.Builder.ExceptionHandlerExtensions.UseExceptionHandler%2A) executes the configured exception handler when an exception has occurred. If the exception handler, configured via <xref:Microsoft.AspNetCore.Builder.ExceptionHandlerOptions.ExceptionHandlingPath>, can't be found, an HTTP 404 response is produced. The response is misleading in that it:
4+
5+
* Seems to be a user error.
6+
* Obscures the fact that an exception occurred on the server.
7+
8+
To address the misleading error in ASP.NET Core 5.0, the `ExceptionHandlerMiddleware` throws the original exception if the exception handler can't be found. As a result, an HTTP 500 response is produced by the server. The response will be easier to examine in the server logs when debugging the error that occurred.
9+
10+
For discussion, see GitHub issue [dotnet/aspnetcore#25288](https://github.com/dotnet/aspnetcore/issues/25288).
11+
12+
#### Version introduced
13+
14+
5.0 RC 1
15+
16+
#### Old behavior
17+
18+
The Exception Handler Middleware produces an HTTP 404 response if the configured exception handler can't be found.
19+
20+
#### New behavior
21+
22+
The Exception Handler Middleware throws the original exception if the configured exception handler can't be found.
23+
24+
#### Reason for change
25+
26+
The HTTP 404 error doesn't make it obvious that an exception occurred on the server. This change produces an HTTP 500 error to make it obvious that:
27+
28+
* The problem isn't caused by a user error.
29+
* An exception was encountered on the server.
30+
31+
#### Recommended action
32+
33+
There are no API changes. All existing apps will continue to compile and run. The exception thrown is handled by the server. For example, the exception is converted to an HTTP 500 error response by [Kestrel](/aspnet/core/fundamentals/servers/kestrel) or [HTTP.sys](/aspnet/core/fundamentals/servers/httpsys).
34+
35+
#### Category
36+
37+
ASP.NET Core
38+
39+
#### Affected APIs
40+
41+
None
42+
43+
<!--
44+
45+
#### Affected APIs
46+
47+
Not detectable via API analysis
48+
49+
-->

0 commit comments

Comments
 (0)