Skip to content

Add and update concurrency Not Found coverage - #37650

Merged
guardrex merged 5 commits into
mainfrom
guardrex/blazor-movie-db-tutorial-concurrency-updates
Sep 17, 2026
Merged

guardrex merged 5 commits into
mainfrom
guardrex/blazor-movie-db-tutorial-concurrency-updates

Conversation

@guardrex

@guardrex guardrex commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #37581
Fixes #37623

Thanks @shaunplumb-sue 🚀 for the issue and Ilona 🎷for great assistance ... and patience! 😄

Related: dotnet/Scaffolding#3828
Related: dotnet/blazor-samples#665

In the tutorial, we'll call out manually adding a return statement after the NotFound call. There are two explicit notes about the situation that I'll remove when the public fix for dotnet/Scaffolding#3828 goes out.

In Part 3, I only mention it in passing because the dev is just reviewing code in Part 3. It's in Part 4's concurrency demo where they'll have trouble with SQLite without the change, and it's in Part 4 that concurrency is discussed in more detail. So, I mention it in Part 3 but have them take action in Part 4.

In the Not Found coverage, we should also remark on placing a return. I'm not sure if I have it exactly right, but we can start with the draft coverage here.

I recommend per what's on the PR that we also roll in some coverage for per-page/component interactive rendering. Not Found works during pre-rendering in this case, so we can call that out because a component might need to toss a 404/Not Found page during component initialization.

Now, I kind'a still would like to show the alternative to the Not Found feature for per-page/component after prerendering. Namely .........

In a given component ...

@rendermode InteractiveServer
@inject NavigationManager Navigation
// Non-prerendered code that needs to lead to a Not Found response (e.g., in a click handler):
Navigation.NavigateTo("/redirect-not-found");

In the Program file ...

app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
app.MapGet("/redirect-not-found", () => Results.NotFound());

... but that's up to you, Ilona. If it's too hacky/workaround-ish 😄, then I understand not placing it. I'll keep it in mind in case a dev writes in to ask about it if we don't add it as well.

Right after this merges, I'll go over to the Blazor samples repo and merge dotnet/blazor-samples#665.

After the scaffolder template is updated, I'll circle around and work #37649 to drop the special step in the tutorial to add a return statement.


Internal previews

File Preview link
aspnetcore/blazor/fundamentals/navigation.md Learn preview
aspnetcore/blazor/tutorials/movie-database-app/part-3.md Learn preview
aspnetcore/blazor/tutorials/movie-database-app/part-4.md Learn preview

Build report

This comment was marked as outdated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Two moderate documentation issues remain unresolved.

Review details

Suppressed comments (3)

aspnetcore/blazor/fundamentals/navigation.md:383

  • This example never assigns an interactive render mode, so it doesn't actually demonstrate the per-page/component case or the prerender-to-interactive transition that RendererInfo.IsInteractive is intended to distinguish. Add @rendermode InteractiveServer to a Razor component example (and change the fence accordingly), consistent with the render-mode examples in aspnetcore/blazor/components/render-modes.md:126-135; otherwise readers can copy this into a static component and miss why the condition is required.
When a component is rendered with a per-page/component interactive render mode, calling <xref:Microsoft.AspNetCore.Components.NavigationManager.NotFound%2A> signals the Blazor router to render the `NotFound` component ***only during prerendering*** (<xref:Microsoft.AspNetCore.Components.RendererInfo.IsInteractive?displayProperty=nameWithType>):

```csharp
protected override void OnInitialized()

aspnetcore/blazor/fundamentals/navigation.md:397

  • Use a csharp fence for this block: it contains only a C# method, not Razor markup. The current razor fence causes incorrect syntax highlighting and differs from the preceding C# lifecycle example; use razor only for the complete component examples that include directives or markup.
```razor

aspnetcore/blazor/tutorials/movie-database-app/part-4.md:324

  • This workaround is also needed by the identical .NET 10 UpdateMovie sample in aspnetcore/blazor/tutorials/movie-database-app/part-3.md (the concurrency code at lines 766-791), which still calls NotFound() and then falls through to NavigateTo("/movies"). Because Part 3 is encountered before this note in the tutorial, readers can copy the same faulty flow without seeing the fix; please update that sample or add equivalent guidance there as part of this change.
> [!IMPORTANT]
> Due to a bug in the Blazor CRUD template, a `return` statement is missing from the `UpdateMovie` method after <xref:Microsoft.AspNetCore.Components.NavigationManager.NotFound%2A> is called. The purpose of calling `return` is to ensure the handler (the `UpdateMovie` method) selects only the Not Found outcome, independently of a given database provider synchronously or asynchronously executing <xref:Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync%2A>. We're in the process of updating the `Edit` component template, and this article will be updated when the scaffolder generates the correct code.
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@guardrex
guardrex requested a review from ilonatommy September 15, 2026 16:13
Comment thread aspnetcore/blazor/fundamentals/navigation.md Outdated
Comment thread aspnetcore/blazor/fundamentals/navigation.md Outdated
Comment thread aspnetcore/blazor/fundamentals/navigation.md Outdated
Comment thread aspnetcore/blazor/fundamentals/navigation.md Outdated
Comment thread aspnetcore/blazor/fundamentals/navigation.md Outdated
Comment thread aspnetcore/blazor/fundamentals/navigation.md Outdated
Co-authored-by: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com>
Co-authored-by: Luke Latham <1622880+guardrex@users.noreply.github.com>
@guardrex

Copy link
Copy Markdown
Collaborator Author

Thx, @ilonatommy ... see if that per-page/component language based on your 2nd suggestion works.

@ilonatommy ilonatommy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just typos. (I cannot apply to not to loose approval power 😉 )

Comment thread aspnetcore/blazor/fundamentals/navigation.md Outdated
Comment thread aspnetcore/blazor/tutorials/movie-database-app/part-3.md Outdated
Co-authored-by: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com>
@guardrex
guardrex merged commit b102ea8 into main Sep 17, 2026
5 checks passed
@guardrex
guardrex deleted the guardrex/blazor-movie-db-tutorial-concurrency-updates branch September 17, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants