I've got a Blazor 8.0 app. I used the default Blazor template with identity logging. When I use <Routes @rendermode="InteractiveServer"/> logging page and few others located in specific directories start blinking and have infinite refresh loop, but some other pages work just fine.
This is my program.cs:
using Microsoft.AspNetCore.Components.Authorization;using Microsoft.AspNetCore.Identity;using Microsoft.EntityFrameworkCore;using BlazorApp1.Components;using BlazorApp1.Components.Account;using BlazorApp1.Data;var builder = WebApplication.CreateBuilder(args);// Add services to the container.builder.Services.AddRazorComponents() .AddInteractiveServerComponents();builder.Services.AddCascadingAuthenticationState();builder.Services.AddScoped<IdentityUserAccessor>();builder.Services.AddScoped<IdentityRedirectManager>();builder.Services.AddScoped<AuthenticationStateProvider, IdentityRevalidatingAuthenticationStateProvider>();builder.Services.AddAuthentication(options => { options.DefaultScheme = IdentityConstants.ApplicationScheme; options.DefaultSignInScheme = IdentityConstants.ExternalScheme; }) .AddIdentityCookies();var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlite(connectionString));builder.Services.AddDatabaseDeveloperPageExceptionFilter();builder.Services.AddIdentityCore<ApplicationUser>(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores<ApplicationDbContext>() .AddSignInManager() .AddDefaultTokenProviders();builder.Services.AddSingleton<IEmailSender<ApplicationUser>, IdentityNoOpEmailSender>();var app = builder.Build();// Configure the HTTP request pipeline.if (app.Environment.IsDevelopment()){ app.UseMigrationsEndPoint();}else{ app.UseExceptionHandler("/Error", createScopeForErrors: true); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts();}app.UseHttpsRedirection();app.UseStaticFiles();app.UseAntiforgery();app.MapRazorComponents<App>() .AddInteractiveServerRenderMode();// Add additional endpoints required by the Identity /Account Razor components.app.MapAdditionalIdentityEndpoints();app.Run();And App.razor:
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><base href="/"/><link rel="stylesheet" href="bootstrap/bootstrap.min.css"/><link rel="stylesheet" href="app.css"/><link rel="stylesheet" href="BlazorApp1.styles.css"/><link rel="icon" type="image/png" href="favicon.png"/><HeadOutlet/></head><body><Routes @rendermode="InteractiveServer"/><script src="_framework/blazor.web.js"></script></body></html>I reduced the blinking page to @page "/Account/Login"and layout to
@inherits LayoutComponentBase@BodyWhat is wrong?