How does antiforgery protection work for Blazor SSR forms in .NET 8?

Last updated 5 July 2026

  • During SSR, EditForm automatically renders an AntiforgeryToken hidden field paired with a cookie token (double-submit pattern: both values must match).

  • app.UseAntiforgery() (added by the template after routing/auth) validates the token on form POSTs to Razor Component endpoints by default.

  • A raw HTML <form> needs an explicit <AntiforgeryToken />. The check mainly protects the static SSR POST path, since interactive forms run over SignalR or in-process.

  • https://learn.microsoft.com/en-us/aspnet/core/blazor/forms/?view=aspnetcore-10.0
  • https://learn.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-10.0
  • https://www.telerik.com/blogs/how-capture-user-input-using-blazor-forms
  • https://learn.microsoft.com/en-us/aspnet/core/release-notes/aspnetcore-8.0?view=aspnetcore-10.0
  • https://khalidabuhakmeh.com/posts/blazor-html-forms-submitting-and-antiforgery-tokens/
  • https://github.com/dotnet/aspnetcore/issues/50612
All Blazor interview questions