Skip to content

Fix Blazor web app template Error.razor: make RequestId public for [PersistentState]#66245

Merged
akoeplinger merged 2 commits intomainfrom
copilot/fix-blazor-error-page-issue
Apr 10, 2026
Merged

Fix Blazor web app template Error.razor: make RequestId public for [PersistentState]#66245
akoeplinger merged 2 commits intomainfrom
copilot/fix-blazor-error-page-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

Navigating to /Error in a newly scaffolded 11.0 Blazor Server app crashes with InvalidOperationException: A public property 'RequestId' on component type '...Error' with a public getter wasn't found. — a regression introduced when [PersistentState] was added to the template.

Description

[PersistentState] requires a public getter, but the template declared RequestId as private:

// Before (broken)
[PersistentState]
private string? RequestId { get; set; }

// After (fixed)
[PersistentState]
public string? RequestId { get; set; }
  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

…ntState attribute

Agent-Logs-Url: https://github.com/dotnet/aspnetcore/sessions/108820f8-6bce-4d6a-abb9-cc9c808fe2cd

Co-authored-by: oroztocil <79744616+oroztocil@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error page opening issue in Blazor web app Fix Blazor web app template Error.razor: make RequestId public for [PersistentState] Apr 9, 2026
Copilot AI requested a review from oroztocil April 9, 2026 13:59
@akoeplinger akoeplinger marked this pull request as ready for review April 9, 2026 14:01
Copilot AI review requested due to automatic review settings April 9, 2026 14:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a regression in the Blazor Web App (C#) template where navigating to /Error crashes because a [PersistentState]-annotated property (RequestId) was not publicly readable.

Changes:

  • Update RequestId from private to public so [PersistentState] can bind/restore it correctly.

Comment on lines 31 to 33
[PersistentState]
private string? RequestId { get; set; }
public string? RequestId { get; set; }

Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

The template regression was only caught by manual navigation to /Error, and the existing Blazor web template E2E tests don’t appear to exercise this route at all. Consider adding a template test assertion that requesting/navigating to /Error succeeds (e.g., status code OK and page renders) to prevent this from regressing again.

Copilot uses AI. Check for mistakes.
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.

@copilot can you please open a new PR with a test?

@akoeplinger akoeplinger merged commit 1ceb83f into main Apr 10, 2026
29 checks passed
@akoeplinger akoeplinger deleted the copilot/fix-blazor-error-page-issue branch April 10, 2026 12:51
@dotnet-policy-service dotnet-policy-service Bot added this to the 11.0-preview4 milestone Apr 10, 2026
Copilot AI added a commit that referenced this pull request Apr 10, 2026
javiercn pushed a commit that referenced this pull request Apr 10, 2026
…ersistentState] (#66245)

* Initial plan

* Fix Error.razor template: make RequestId property public for PersistentState attribute

Agent-Logs-Url: https://github.com/dotnet/aspnetcore/sessions/108820f8-6bce-4d6a-abb9-cc9c808fe2cd

Co-authored-by: oroztocil <79744616+oroztocil@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: oroztocil <79744616+oroztocil@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components

Projects

None yet

4 participants