web-api POST body object always null

前端 未结 26 3050
余生分开走
余生分开走 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条回答
  •  旧时难觅i
    2020-11-27 15:15

    Seems like there can be many different causes of this problem...

    I found that adding an OnDeserialized callback to the model class caused the parameter to always be null. Exact reason unknown.

    using System.Runtime.Serialization;
    
    // Validate request
    [OnDeserialized]  // TODO: Causes parameter to be null
    public void DoAdditionalValidatation() {...}
    

提交回复
热议问题