Tags

#minimal-api
minimal-api

3stories
Oct 25latest
ASP.NET Core
Test 404 without a server
DVDEV Community: #aspnetcore Sukhpinder Singh Oct 25

Test Minimal API 404 branches without booting a server

The author shows how to test the 404 branch of a minimal API endpoint by calling the handler directly instead of booting WebApplicationFactory. Typed result unions such as Results<Ok<T>, NotFound> make the return type a compiler-checked contract. The approach gives fast, readable unit tests, while the author keeps a thin layer of integration tests for routing, binding and middleware.

ASP.NET Core 10
Wrong page from cache
DVDEV Community: #aspnetcore Sukhpinder Singh Oct 22

SetVaryByQuery Can Make ASP.NET Core Output Cache Serve Wrong Pages

The article explains how calling SetVaryByQuery in an ASP.NET Core output cache policy replaces the default vary-by-all-query-keys behavior. A policy that names only sort stops varying by page, so different pages can receive the same cached body. The author reproduces the bug with a small test and shows the fix.

ASP.NET Core 11
Validation messages translated
KAKhalid Abuhakmeh Khalid Abuhakmeh Oct 20

Localize Minimal API validation messages in .NET 11

ASP.NET Core 11 adds built-in localization for validation messages and display names in Minimal APIs and Blazor. Registering AddValidation and AddLocalization, plus culture-specific resx files, is enough to return 400 responses in the caller's language. The author shows a working sample and an integration test across four cultures.

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message