Skip to content

Server validation with a validator component upgrade #36051

Closed

Description

@guardrex

Description

Per Ondřej's suggestion in #35972 (for .NET 6 or later because Minimal APIs didn't arrive until .NET 6) ...

  • Idea: Replace use of MVC controller with Minimal API in the section "Server validation with a validator component" to showcase the unified validation experience
    • The API controller uses MVC-based validation which also uses DataAnnotations attribute to specify validation rules. However, it is configured differently and might have different behavior in some cases (e.g. validation is skipped with ValidateNever attribute in MVC but with SkipValidation attribute in the unified validation code)
    • Up for debate: Speaking of "server validation" and "client validation" might also be a bit confusing in the context of Blazor Server - maybe rephrase the section using terminology such as "data API", "backend", or "backend API"?

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/forms/validation?view=aspnetcore-9.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/forms/validation.md

Document ID

bcb470e1-c859-0549-b4ef-c6c9b7ef2c72

Platform Id

b4c1bad9-fc7a-21f5-2552-f0f3617f77db

Article author

@guardrex

Metadata

  • ID: bcb470e1-c859-0549-b4ef-c6c9b7ef2c72
  • PlatformId: b4c1bad9-fc7a-21f5-2552-f0f3617f77db
  • Service: aspnet-core
  • Sub-service: blazor

Related Issues

Activity

  1. added
    Source - Docs.ms
    on Sep 4, 2025
  2. github-actions commented on Sep 4, 2025

    @github-actions
    Contributor

    🏖️🌞 Summertime!! Woot!! 🏐⛵

    Stand-by! ... A green dinosaur 🦖 will be along shortly to assist.

  3. added and removed
    Source - Docs.ms
    on Sep 4, 2025
  4. moved this from Triage to P2 - Medium Priority in Blazor.Docson Sep 4, 2025
  5. moved this from P2 - Medium Priority to In progress in Blazor.Docson Apr 22, 2026
  6. guardrex commented on Apr 23, 2026

    @guardrex
    Author
  7. guardrex commented on May 7, 2026

    @guardrex
    CollaboratorAuthor

    Note that the unified validation experience wasn't rolled into the approach. I'm rolling it in on the PR.

  8. guardrex commented on May 7, 2026

    @guardrex
    CollaboratorAuthor

    @oroztocil ... It's not going very well thus far for the unified experience. As you're well aware, the unified experience out of a Minimal API is to send back a 400 - Bad Request with ProblemDetails when model validation fails. A BWA using Microsoft.Identity.Web's CallApiForUserAsync throws 💥 on a 400 - Bad Request by design. When I trap the exception, I lose the ProblemDetails payload. I'll need to work with it a bit more to figure out an approach that will work ... unless you're already aware of this problem and know what to do.

  9. guardrex commented on May 7, 2026

    @guardrex
    CollaboratorAuthor

    This approach that AI discusses might work in this scenario ...

    Custom Exceptions: For cleaner architecture, many developers create a custom exception that accepts the HttpResponseMessage as a parameter to store and expose the response body for further evaluation.

    Naaaaah ... not looking good.

    I'm going to take a break and come back. I'm hitting a 🧠🔥 at the moment. We might not be able to recommend using CallApiForUserAsync with the unified experience and a Minimal API. Thus far, it's really fighting me to do it that way.

  10. moved this from In progress to Done in Blazor.Docson Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions