Asp.net core MVC post parameter always null

后端 未结 4 1003
一整个雨季
一整个雨季 2020-12-05 10:57

I am new to MVC core.

I have created a project with MVC core which has a controller. This controller has Get and Post action methods. If i pass data to Get method us

4条回答
  •  渐次进展
    2020-12-05 11:26

    Note the original method Post([FromBody] User newUser)

    For future readers from google, this same issue could arise if the method was Post(User newUser)

    Note the lack of [FromBody]. This is a departure from previous versions of MVC where these parameters were generally inferred.

    If you're an existing MVC5 developer who finds this page regarding AspNetCore.MVC, make sure to double check that you have [FromBody] decorated where relevant.

提交回复
热议问题