Ensure host wiring when scaffolding Blazor Identity - #3825
Merged
Merged
Conversation
…fer/Scaffolding into 2694_ScaffoldException
…to 2694_ScaffoldException
…fer/Scaffolding into 2694_ScaffoldException
irfanajaffer
marked this pull request as ready for review
September 18, 2026 07:37
Member
|
happy to review after merge conflicts are resolved |
haileymck
reviewed
Sep 22, 2026
haileymck
reviewed
Sep 22, 2026
haileymck
reviewed
Sep 22, 2026
haileymck
approved these changes
Sep 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2694
Summary
This PR updates the Blazor Identity scaffolder to automatically apply the
required host-level integration changes when Identity is scaffolded into a
Blazor Web App.
Previously, Identity pages were generated successfully, but the application
was not fully configured to support them, resulting in runtime failures when
navigating to Identity endpoints.
Problem
The Identity scaffolder generated the Account components but did not apply
the additional host wiring required for those components to function in a
Blazor Web App.
As a result:
Changes
Program.csAdded the required Identity-related application configuration:
AddCascadingAuthenticationState()MapAdditionalIdentityEndpoints()App.razorUpdated the generated configuration to support Identity pages that require
non-interactive routing.
Additional Identity Integration
Integrated the host-level changes directly into the scaffolding workflow so
that newly scaffolded applications are configured automatically without
requiring manual updates.
Integration Tests
This PR adds/updates integration tests to verify that host wiring and
generated files are created as expected. Key test expectations include:
Program.cscontains the required Identity serviceregistrations.
MapAdditionalIdentityEndpoints()is present in the generated host file.IdentityRedirectManager,IdentityUserAccessor, and the authenticationstate provider are registered.
App.razorcontains the expected non-interactive routingconfiguration for Identity pages.
ApplicationUser.cs, the requested DbContext, and Identity account pagesare created.
The .NET 8 coverage is provided by
BlazorIdentityNet8IntegrationTests.Scaffold_BlazorIdentity_Net8_CliInvocation.The test now performs these checks unconditionally instead of passing when
the scaffolder produces no Identity files.
Validation
Validated by:
App.razor.Compatibility
scaffolder.
Apps.
.NET 8 compatibility note
.NET 8 Blazor Identity scaffolding already has dedicated templates and a
code-modification configuration in this repository. This PR extends the new
host wiring to that configuration and fixes the .NET 8 template selection so
the expected Identity files are generated.
.NET 8 does not provide
HttpContext.AcceptsInteractiveRouting()orExcludeFromInteractiveRouting. Its generatedApp.razortherefore uses aframework-compatible path check to disable interactive rendering for
/Accountroutes while retaining interactive server rendering elsewhere.This behavior is validated by the .NET 8 integration test, which confirms
the generated files,
Program.csregistrations and endpoint mapping,App.razorrouting changes, and a successful post-scaffolding build.Tests
CodeModification configs used to insert host wiring.
Screenshot reference