ASP.NET Core FromBody: Not working? Or returning null? (Solution)



ASP.NET Core FromBody: Not working? Or returning null? (Solution)

ASP.NET Core FromBody: Not working? Or returning null? (Solution)

The ASP.NET Core FromBody. Is it not working? Or returning null? This video will provide a solution to this common .NET problem.

We’ve made a JSON request to an API endpoint. But, two potential issues are arising. Maybe our request is not binding properly and returning null? Or maybe, we are getting a 415 unsupported media type error?

In this video, we will look at two ways on how to set up a controller for an ASP.NET Core Web API.

Using C#, we will write some API endpoints for a HTTP GET request and a HTTP POST request.

Afterwards, we will run the application and perform the HTTP GET request using a querystring. In addition, we will do three HTTP POST requests using the following content types:

– form-data
– x-www-form-url-encoded
– application/json

We will demonstrate when we need to include the FromBody attribute, and when we need to use the FromQuery attribute.

In addition, we will explore the differences in behaviour when we use the ApiController attribute.

You will find that it behaves differently with a JSON request when using the ApiController attribute.

💻 Download the code sample for this demo 💻
https://www.roundthecode.com/dotnet-samples/a-frombody-and-fromquery-sample-in-asp-net-core-web-api?utm_source=youtube&utm_medium=referral&utm_campaign=4VwotucTV_o+-+video+content+%28code+sample%29

📖 Learn .NET and C# with our online courses 📖
https://www.roundthecode.com/dotnet-c-sharp-courses?utm_source=youtube&utm_medium=referral&utm_campaign=4VwotucTV_o+-+video+content+%28online+course%29

â–º More Information: https://www.roundthecode.com/dotnet/asp-net-core-web-api/why-asp-net-core-frombody-not-working-returning-null?utm_source=youtube&utm_medium=referral&utm_campaign=4VwotucTV_o+-+video+content+%28more+information%29

#aspnetcore #frombody #fromquery

Comments are closed.