Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Why is my Blazor EditForm not calling OnValidSubmit on /auth/register route?

$
0
0

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.cs uses:

    builder`.Services.AddRazorComponents()                  .AddInteractiveServerComponents();  app.MapRazorComponents<App>()         .AddInteractiveServerRenderMode(); 
  • Register.razor is the only component with @page "/auth/register" and contains the EditForm with a submit <button type="submit">.

  • MainLayout.razor has no @page directive.

  • 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:

  1. Under what conditions would Blazor render my Register.razor page as a plain HTML form (<form method="post">) instead of a proper interactive EditForm so that OnValidSubmit never fires?

  2. What should I check to ensure that the /auth/register route is actually served by the Blazor component and not by some MVC/Razor Page or old artifact?

  3. 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.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>