question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Web API Controller generation: Missing [FromBody] attribute on .NET Core

See original GitHub issue

ASP.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:closed
  • Created 6 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nmcccommented, Nov 24, 2017

I’ll give it a try within my free time 😄

0reactions
RicoSutercommented, Feb 14, 2018

And please use fully qualified types (with namespace) so that no usings are required

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found