【发布时间】:2020-03-11 01:17:44
【问题描述】:
我有这个方法,看起来有点像这样:
/// <summary>
/// Updates the status to paid
/// </summary>
/// <param name="data">The data from world pay</param>
/// <returns></returns>
[HttpPost]
[Consumes("application/x-www-form-urlencoded")]
public IActionResult Residential([FromForm] string data)
{
if (string.IsNullOrEmpty(data)) return BadRequest("No data was present");
var model = JsonConvert.DeserializeObject<WorldPayResponseModel>(data);
// ----- removed from brevity ----- //
return Ok(true);
}
当我使用邮递员发送一些数据时,它总是为空。
有人知道为什么会这样吗?
【问题讨论】:
-
你有没有想过这个问题?我也有同样的问题。
-
使用
IActionResult Method([FromForm] IFormCollection form)而不是string
标签: c# asp.net-core-webapi x-www-form-urlencoded