ASP.NET Core FromForm And FromBody Same Action

后端 未结 1 904
春和景丽
春和景丽 2020-12-11 01:02

Can I have both FromForm and FromBody attributes to action ?

public IActionResult Index([FromBody][FromForm] Person model){
.....
}
相关标签:
1条回答
  • 2020-12-11 01:44

    No, it's not possible.

    The FromForm attribute is for incoming data from a submitted form sent by the content type application/x-www-url-formencoded while the FromBody will parse the model the default way, which in most cases are sent by the content type application/json, from the request body.

    0 讨论(0)
提交回复
热议问题