Repository navigation
Avoid SectionRenderModeMismatch warning for PageTitle in default Blazor apps - #69832
Conversation
…to Counter (Server) in per page Web app template
…to Counter (Server) in Web App page per rendermode template
|
Thanks for your PR, @karmegams02. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
There was a problem hiding this comment.
🟡 Changes recommended
The warning’s static-rendering remediation is incorrect for interactive-outlet/static-content mismatches.
1 open finding
What changed in this PR
Improves Blazor head-section mismatch diagnostics and suppresses the expected default-template PageTitle warning.
Changes:
- Adds descriptive built-in section identifiers.
- Demotes static-outlet/interactive-title mismatches to Debug.
- Adds render-mode coverage and documents the behavior.
| File | Description |
|---|---|
SectionRegistry.cs |
Selects diagnostic severity and updates guidance. |
HeadOutlet.cs |
Adds descriptive head-section identifiers. |
EndpointHtmlRendererTest.cs |
Tests diagnostic behavior across render modes. |
BlazorComponentsGuidance.md |
Documents the diagnostic policy and limitation. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
From what I see, this just downgrades this particular warning to Debug when |
Keep Counter pages and PageTitle static for per-page interactivity and move interactive controls into child components. Preserve global interactivity and cover title navigation, reloads, and section mismatch diagnostics. Fixes dotnet#69673 Co-authored-by: Copilot <[email protected]>
…pPerPage. -Added these changes only for the page per rendermode template sample.
|
Thanks @dariatiurina and @kotlarmilos for the guidance. I've revised the implementation to address the template's render-mode boundary rather than downgrade the framework warning. This update supersedes the diagnostic/log-level approach described in the original PR description. The framework diagnostic changes have been removed, and section render-mode mismatch warnings remain unchanged. Updated approachFor per-page interactivity, the generated Counter page now keeps its constant page title and heading in the static component tree. Only the counter state, button, and event handler move into a child component with the appropriate interactive render mode:
This keeps the page title and the static head outlet in the same render-mode boundary while preserving counter interactivity. For global interactivity, the existing Counter implementation is retained, and the additional child component is excluded from generation. The per-page Blazor Web App sample has also been updated to follow the same pattern. |
… section_rendermode_warning # Conflicts: # src/ProjectTemplates/test/Templates.Blazor.Tests/BlazorWebTemplateTest.cs
|
/review |
|
Copilot's local review panel found no issues to raise at this commit. |
|
@karmegams02 I am not following the changes. How the razor page fixes the problem? PR description is too long and hard to read. |
|
@kotlarmilos , I’ve shortened the PR description and clarified how the change resolves the warning. Previously, Moving |
|
✅ No documentation PR was created. Confidence that documentation is needed: 30% No docs needed: a bug fix restructuring the template Counter page to avoid a render-mode mismatch warning. A maintainer could optionally review whether any docs quote the template's Counter markup. Documentation surfaces considered
|

Description
Fix the
SectionRenderModeMismatchwarning emitted when visiting the Counter page in a Blazor Web App configured for per-page/component interactivity.Root cause
App.razorcontains aHeadOutletrendered using static server-side rendering (SSR).HeadOutletinternally usesSectionOutlet, while the Counter page'sPageTitleusesSectionContent.The Counter page declares an interactive render mode selected by the template, so its
PageTitleinherits that mode. This placesSectionContentandSectionOutletacross different render-mode boundaries, triggering the warning during prerendering even though the constant title displays and the counter works.Fix
Move the render-mode directive, counter markup, state, and event handling into a child
CounterContentcomponent. KeepPageTitleinCounter.razoroutside the interactive boundary.For per-page interactivity,
PageTitleandHeadOutletnow both use static SSR, whileCounterContentremains interactive. Preserve the existing implementation for global interactivity, update the sample and template baselines, and add a Chromium regression test checking counter interaction without the warning.Test
The Chromium test runs a Blazor Web App with per-page Server interactivity, navigates to Counter, verifies that clicking the button increments the count, and checks that no section render-mode mismatch warning appears in the server output.
Fixes #69673