Minifycode 2022-05-18 Viewed 1.3K times ASP.Net Core MVC

In this article you will learn what is [FromBody] in .net core web API, This article describes how Web API binds parameters, and how you can customize the binding process. When Web API calls a method on a controller, it must set values for the parameters, a process called binding, the [FromBody] attribute which inherits ParameterBindingAttribute class is used to populate a parameter and its properties from the body of an HTTP request. The ASP.NET runtime delegates the responsibility of reading the body to an input formatter. 
When [FromBody] is applied to a complex type parameter, source parameter applied to its properties are ignored.

 

[HttpPost("test")]
        public string test([FromBody] string name)
        {
            string n = name;
            return n;
        }

 

Response: Only return- Test

 

what is [FromBody] in .net core web API, This article describes how Web API binds parameters, and how you can customize the binding process. When Web API calls a method on a controller.
minify code