Web API Controller generation: Missing [FromBody] attribute on .NET Core
See original GitHub issueASP.NET WebApi Core requires Controller parameters that are built from parsing the HTTP request body to have the corresponding parameter to be decorated with the attribute [FromMember]
e.g.
public void Post([FromBody]string value)
I’m using the swaggerToCSharpController
generator to generate Controllers targeting .NET Core 2.0.
I’ve followed these instructions to configure the generator, and I could get the generated code to compile properly.
But because the [FromMember]
attribute is not generated, those parameters are not deserialized from the Request Body.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
ASP.NET Core - weird behavior with [FromBody]
I have an ASP.NET Core web app that works fine, when using this controller implementation: [HttpPost] public ActionResult SetAssignment() { ...
Read more >Why is the ASP.NET Core FromBody not working or ...
Well, there is one reason why this is happening. There is an [ApiController] attribute attached to the controller. When an ASP.NET Core Web...
Read more >Model Binding in ASP.NET Core
Apply the [FromBody] attribute to a parameter to populate its properties from the body of an HTTP request. The ASP.NET Core runtime ...
Read more >What is .Net Core Web Api Model Validation error ...
Hi All,. I have made an .NET core web API endpoint that takes a model in parameter from body. I have purposely generated...
Read more >From MVC to Minimal APIs with ASP.NET Core 6.0 - Ben Foster
ASP.NET 6.0 introduces an alternative way to build HTTP APIs, using the aptly named “Minimal APIs”. This post provides a step-by-step guide ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ll give it a try within my free time 😄
And please use fully qualified types (with namespace) so that no usings are required