I am trying to force the Controller to bind a simple type from the request body
So I post through jquery ajax
var params = {source,"example"}$.ajax({ type: "POST", url: wsurl, contentType: "application/json", data: JSON.stringify(params), dataType: "json", success: onSuccess })
I can receive that on the controller when using [FromBody] and creating a simple Model
public class stringParm
{
public string source{ get; set; }
}
[HttpPost] public string[] myAction([FromBody] stringParm s) { return new string[] s.source }
but this does not work (ASP.NET Core 1.1) when using
[HttpPost] public string[] myAction([FromBody] string source) { return new string[] source }
In that case, source is always null.
Any suggestions on how to make this work?
Thx, Pieter