liveBook · Manning

FromBody attribute

The FromBody attribute directs ASP.NET Core model binding to deserialize a parameter or property value from the HTTP request body.

How 2 Manning books explain it

ASP.NET Core in Action, 3e

The FromBody attribute is an ASP.NET Core parameter-binding attribute that specifies binding a parameter from the deserialized HTTP request body.

How it is used
Directs ASP.NET Core model binding to obtain a parameter from JSON content in an HTTP request body.
How deep it goes
Explains JSON deserialization, binding-source precedence, media-type failures, verb restrictions, and multiple-body-parameter errors.
Examples
Uses a Product record in a POST endpoint and a List<Photo> parameter in a Razor Pages handler.
What you can do after
Apply it via ASP.NET Core handler parameters to select JSON body binding and avoid common request-shape errors.

Read how ASP.NET Core in Action, 3e explains FromBody attribute →

Pro ASP.NET Core 7, Tenth Edition

The FromBody attribute is an ASP.NET Core parameter attribute that specifies that a parameter value should be read from the HTTP request body.

How it is used
Selects the HTTP request body as the model-binding source for an action parameter receiving JSON.
How deep it goes
Shows parameter placement and a working POST request, but defers the complexities of model binding and data validation.
Examples
Uses Product actions and PowerShell JSON POST and PUT requests, including a POST whose bound object is returned.
What you can do after
Apply it via ASP.NET Core MVC to bind a JSON request body to a controller action parameter.

Read how Pro ASP.NET Core 7, Tenth Edition explains FromBody attribute →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.