public class NumberModel
{
public int Number { get; set; }
}
[HttpPost("method")]
public IActionResult Method([FromBody] NumberModel model)
{
return Ok(model.Number);
}
Will automatically format it as Json. Since Number is an integer, it will be returned as a string representation of the number. If you just return Ok(model)it will return a json object like{ 'Number' : 3 }
source
share