© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
2 replies
Thinker

❔ How does ASP.NET deserialize JSON to records?

This isn't specifically related to ASP.NET, but still wondering. If I have an endpoint like this
private sealed record SendRequest(string Content);
private static Task<IResult> Send(
    [FromBody] SendRequest request)
{
    // ...
}
private sealed record SendRequest(string Content);
private static Task<IResult> Send(
    [FromBody] SendRequest request)
{
    // ...
}
then ASP.NET has no problem deserializing the body into the record. But... how does it do that? Just using System.Text.Json it doesn't appear like you can (or I'm doing something wrong), and plus, the properties that records generate don't have setters. How does this work?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

JSON Deserialize
C#CC# / help
2y ago
JSON deserialize
C#CC# / help
2y ago
✅ How to ASP.NET
C#CC# / help
8mo ago