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 →

What to know first

Related concepts

Questions about FromBody attribute

What is FromBody attribute?

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

Which Manning books explain FromBody attribute?

ASP.NET Core in Action, 3e and Pro ASP.NET Core 7, Tenth Edition.

What should I know before learning FromBody attribute?

Manning books that teach FromBody attribute usually introduce dependency injection, form data, JSON and model binding first.

What is the difference between FromBody attribute and ApiController?

The FromBody attribute directs ASP.NET Core model binding to deserialize a parameter or property value from the HTTP request body. ApiController is an ASP.NET Core attribute that enables API-specific conventions and behavior for controller classes, including request binding and validation handling.

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.