I have a POST method on one of my API controllers that takes a single string value:
public string Post([FromBody] string foo) {
return(fooOracle.ValidateFoo(foo) ? "success" : "failure");
}
I am sending a message with the body of the sending request:
foo=123412341234
(i.e. this is a normal HTTP POST that you can initiate by sending a browser form, as well as using an HTTP client)
As a candidate for WebAPI, this silently stopped working - it no longer binds foo. To make the code work, I had to replace the method with the following:
public string Post(FormDataCollection form) {
var foo = form.Get("foo");
return(fooOracle.ValidateFoo(foo) ? "success" : "failure");
}
This works, but it is a little dirty and requires more thorough testing than the previous version.
- [FromBody] ? , , RC.