From 05aacf08228a950fe280f0f734ff5e70f14be4fa Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Mon, 5 May 2025 11:51:36 -0400 Subject: [PATCH] Improve async void guidance --- aspnetcore/blazor/components/event-handling.md | 3 +++ aspnetcore/blazor/components/index.md | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/aspnetcore/blazor/components/event-handling.md b/aspnetcore/blazor/components/event-handling.md index 20aef0c16755..b58d31129c4f 100644 --- a/aspnetcore/blazor/components/event-handling.md +++ b/aspnetcore/blazor/components/event-handling.md @@ -40,6 +40,9 @@ For event handling: :::moniker-end +> [!IMPORTANT] +> The Blazor framework doesn't track `void`-returning asynchronous methods (`async`). As a result, the entire process fails when an exception isn't caught if `void` is returned. Always return a / from asynchronous methods. + The following code: * Calls the `UpdateHeading` method when the button is selected in the UI. diff --git a/aspnetcore/blazor/components/index.md b/aspnetcore/blazor/components/index.md index 79319ee4c515..4a10bde23119 100644 --- a/aspnetcore/blazor/components/index.md +++ b/aspnetcore/blazor/components/index.md @@ -638,7 +638,7 @@ Razor syntax for C# control structures, directives, and directive attributes are ### Asynchronous methods (`async`) don't support returning `void` -The Blazor framework doesn't track `void`-returning asynchronous methods (`async`). As a result, exceptions aren't caught if `void` is returned. Always return a from asynchronous methods. +The Blazor framework doesn't track `void`-returning asynchronous methods (`async`). As a result, the entire process fails when an exception isn't caught if `void` is returned. Always return a / from asynchronous methods. ### Nested components