ASP.NET web api cannot get application/x-www-form-urlencoded HTTP POST

前端 未结 6 616
无人共我
无人共我 2020-12-01 10:53

I\'m new to web-api. I want to receive a HTTP POST data using web-api. The content-type is application/x-www-form-urlencoded, and the request body is like:

6条回答
  •  猫巷女王i
    2020-12-01 11:05

    For asp.net core 3.x you need to supply the correct decorators to handle the request correctly:

    [HttpPost("MyPostHandler")]
    [Consumes("application/x-www-form-urlencoded")]
    public async Task MyPostHandler([FromForm] string id)
    {
    }
    

提交回复
热议问题