The /Account Identity components must remain statically server-rendered in .NET 10; remove any interactive render mode from those pages and migrate the account implementation from a newly generated .NET 10 Individual Accounts template rather than retaining the .NET 8 IdentityUserAccessor pattern.
1. Verify the render-mode problem
Your stack trace is from a Blazor circuit:
Microsoft.AspNetCore.Components.Server.Circuits
That means Login.razor and Manage/Index.razor are rendering interactively. During interactive rendering there is no active HTTP request, so a cascaded HttpContext is expected to be null. It is only available during static server-side rendering (static SSR). Declaring it with default! merely suppresses compiler warnings; it doesn't ensure a value at runtime.^1^
Change the declaration so misuse is visible:
@code {
[CascadingParameter]
private HttpContext? HttpContext { get; set; }
}
Don't treat a null check as the complete login fix. SignInManager.PasswordSignInAsync must modify the HTTP response cookie, which requires an active HTTP request before the response starts.^1^
2. Keep Identity pages out of global interactivity
Inspect Components/App.razor. If it contains unconditional global interactivity such as:
<HeadOutlet @rendermode="InteractiveServer" />
<Routes @rendermode="InteractiveServer" />
then the router propagates Interactive Server mode to routed pages, including /Account unless the app applies the template's special handling for static pages.^2^
The supported template arrangement is:
- Normal application pages can use Interactive Server.
-
Components/Account Identity pages use static SSR.
- Navigation to an Identity operation must cause a normal HTTP request when required, rather than only interactive circuit navigation.
The .NET 10 Identity components themselves don't support interactivity, and the current template includes render-mode handling that keeps Identity components static even when other components are globally interactive.^3^
3. Migrate from the current .NET 10 template
Because Identity Razor components are implementation files generated into the application and are subject to change each release, don't assume the .NET 8 Components/Account folder remains compatible unchanged.^4^
Create a temporary .NET 10 reference project:
dotnet new blazor -au Individual -o Blazor10IdentityReference
Then compare and merge these areas into the upgraded project:
-
Components/App.razor
-
Components/Routes.razor
-
Components/Account
-
Components/_Imports.razor
- Identity registrations and Razor-component mappings in
Program.cs
- Account navigation that forces a full request where the template does so
Do not overwrite your database, migrations, ApplicationUser, connection string, or customized account logic without reviewing the differences first. The generated project contains the current Identity components under Components/Account and the required supporting configuration.^4^
The absence of IdentityUserAccessor in the current template indicates that it shouldn't simply be copied forward as a required .NET 10 service. Replace the old account components that depend on it with their .NET 10 equivalents.
4. For user access in genuinely interactive components
For interactive application components, obtain the current ClaimsPrincipal through Blazor authentication state, not HttpContext.User:
@using Microsoft.AspNetCore.Components.Authorization
@inject AuthenticationStateProvider AuthenticationStateProvider
@code {
private ClaimsPrincipal? currentUser;
protected override async Task OnInitializedAsync()
{
var state =
await AuthenticationStateProvider.GetAuthenticationStateAsync();
currentUser = state.User;
}
}
AuthenticationStateProvider is the appropriate abstraction for determining whether the circuit user is signed in and who that user is.^3^
The later ObjectDisposedException messages are secondary: the original unhandled NullReferenceException terminates the circuit, after which rendering attempts encounter disposed circuit state.
References
-
IHttpContextAccessor/HttpContext in ASP.NET Core Blazor apps
- ASP.NET Core Blazor render modes
- ASP.NET Core Blazor authentication and authorization
- Creates a new ASP.NET Core Blazor Web App project with Individual Accounts authentication using the .NET CLI.