I’m building a Blazor (Razor Components / .NET 8) app and I have a registration page at /auth/register. The component uses an EditForm with OnValidSubmit="HandleRegister". Inside HandleRegister I have a Console.WriteLine("HandleRegister CALLED"), and I also call an API via an injected IAuthService.
The problem: when I submit the form, the handler is never called. There's no message in the server console, no API call, and the browser’s Network tab only shows a POST /auth/register with application/x-www-form-urlencoded, like a classic HTML form. The form HTML in DevTools looks like this:
<form method="post" action="/auth/register"> ... </form> So it seems the page is being rendered as a normal HTML form, not as a Blazor EditForm with interactivity.
Some more details:
I have a router component like this:
<CascadingAuthenticationState\> <Router AppAssembly="@typeof(Program).Assembly"> <Found Context="routeData"> <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> <FocusOnNavigate RouteData="@routeData" Selector="h1" /> </Found> <NotFound> <LayoutView Layout="@typeof(MainLayout)"> <p role="alert">Sorry, there's nothing at this address.</p></LayoutView> </NotFound> </Router> </CascadingAuthenticationState>Program.csuses:builder`.Services.AddRazorComponents() .AddInteractiveServerComponents(); app.MapRazorComponents<App>() .AddInteractiveServerRenderMode();Register.razoris the only component with@page "/auth/register"and contains theEditFormwith a submit<button type="submit">.MainLayout.razorhas no@pagedirective.I do see some warnings in the browser console about Content Security Policy and about a browser extension (
Unchecked runtime.lastError: A listener indicated an asynchronous response...), but they seem unrelated.
My questions:
Under what conditions would Blazor render my
Register.razorpage as a plain HTML form (<form method="post">) instead of a proper interactiveEditFormso thatOnValidSubmitnever fires?What should I check to ensure that the
/auth/registerroute is actually served by the Blazor component and not by some MVC/Razor Page or old artifact?Are there any CSP or other configuration issues that could prevent Blazor from wiring up event handlers like
OnValidSubmit, even though the page seems to load normally?
Any guidance or concrete steps to debug this (what to check in DevTools, project structure, or routing setup) would be appreciated.