Skip to content

Use DebuggerDisableUserUnhandledExceptionsAttribute for things like Blazor NavigationExcetptions  #57085

@halter73

Description

@halter73

We should take advantage of [DebuggerDisableUserUnhandledExceptions] which was recently added to the runtime. dotnet/runtime#103105

In .NET 9, Visual Studio is adding support for catching async user-unhandled exceptions which will be enabled by default. This feature has existed for a long time for synchronous methods, but not for async methods. There are several exceptions in ASP.NET Core that propagate through user code but are expected to be handled by framework code. One example is the NavigationException used to force redirects when calling NavigationManager.NavigateTo() during static Blazor rendering.

Async user unhandled exception

  • NavigationExceptions that are properly handled by Blazor and turned into a redirect is an obvious candidate for this attribute since it is not expected for the user to handle these exceptions.
  • We should also look at using this for exceptions handled by the DeveloperExceptionPageMiddleware and DatabaseDeveloperPageExceptionFilter. The middleware could call Debugger.BreakForUserUnhandledException() in DisplayException which would indicate that not custom filter like the DatabaseDeveloperPageExceptionFilter handled the exception. There could be a custom filter registered that "handles" exceptions that still should be considered unhandled, but I think it's okay to slightly over suppress to begin with considering that the debugger would never break user-unhandled exceptions before .NET 9.

Metadata

Metadata

Assignees

Labels

area-blazorIncludes: Blazor, Razor Componentsarea-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewares

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions