web-api POST body object always null

前端 未结 26 2935
余生分开走
余生分开走 2020-11-27 15:03

I\'m still learning web API, so pardon me if my question sounds stupid.

I have this in my StudentController:

public HttpResponseMessage          


        
26条回答
  •  孤城傲影
    2020-11-27 15:39

    I had this problem in my .NET Framework Web API, because my model existed in a .NET Standard project that referenced a different version of data annotations.

    Adding the ReadAsAsync line below highlighted the cause for me:

    public async Task Register(RegistrationDetails registrationDetails)
    {
        var regDetails = await Request.Content.ReadAsAsync();
    

提交回复
热议问题