Skip to content

Why does /Account/Login briefly render then disappear in a .NET 10 Blazor Web App using InteractiveServer and ASP.NET Identity? #65652

@TheCSharpProgrammer

Description

@TheCSharpProgrammer

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I am building a .NET 10 Blazor Web App (Visual Studio 2026 template) using:

  • Interactive Server components
  • ASP.NET Core Identity
  • EF Core with SQL Server

The application runs normally, but I am having problems implementing a login page.

Problem

When navigating to:

/Account/Login

the login page briefly renders and then disappears (appears to redirect or render NotFound).
The UI "blinks" and the login form cannot be used.

This behavior only occurs when the application becomes interactive.

If interactivity is disabled, the login page renders normally.

Project configuration

Program.cs:

builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents();

builder.Services.AddIdentityCore<ApplicationUser>()
    .AddEntityFrameworkStores<NexaPlatformDbContext>()
    .AddSignInManager()
    .AddDefaultTokenProviders();

app.UseAuthentication();
app.UseAuthorization();

app.MapRazorComponents<App>()
   .AddInteractiveServerRenderMode();

Router configuration

Routes.razor:

<CascadingAuthenticationState>
    <Router AppAssembly="@typeof(Program).Assembly">
        <Found Context="routeData">
            <AuthorizeRouteView RouteData="@routeData"
                                DefaultLayout="@typeof(MainLayout)">
                <NotAuthorized>
                    <RedirectToLogin />
                </NotAuthorized>
            </AuthorizeRouteView>
        </Found>

        <NotFound>
            <p>Not Found</p>
        </NotFound>
    </Router>
</CascadingAuthenticationState>

Login component

@page "/Account/Login"
@attribute [AllowAnonymous]

<form method="post" action="/account/login">

    <AntiforgeryToken />

    <input type="hidden" name="returnUrl" value="@ReturnUrl" />

    <div>
        <label>Email</label>
        <input name="email" />
    </div>

    <div>
        <label>Password</label>
        <input type="password" name="password" />
    </div>

    <button type="submit">Sign in</button>

</form>

@code {
    [SupplyParameterFromQuery(Name = "returnUrl")]
    public string? ReturnUrlQuery { get; set; }

    private string ReturnUrl => string.IsNullOrWhiteSpace(ReturnUrlQuery) ? "/" : ReturnUrlQuery!;
}

Things I have already checked

  • Only one component declares @page "/Account/Login"
  • [AllowAnonymous] is applied to the login page
  • No global [Authorize] attributes exist in _Imports.razor
  • prerendering disabled (InteractiveServerRenderMode(prerender:false))
  • duplicate routes removed
  • minimal API login endpoint works correctly

Expected Behavior

When I click login, i should be taken to login page and be able to login without it appearing for a second then saying not found.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions