No MediaTypeFormatter is available to read an object of type 'Advertisement' in asp.net web api

前端 未结 3 951
悲哀的现实
悲哀的现实 2021-02-18 18:13

I have a class that name is Advertisement:

 public class Advertisement
{
    public string Title { get; set; }
    public string Desc { get; set; }
}
         


        
3条回答
  •  深忆病人
    2021-02-18 18:33

    In your WebApiConfig.cs add this inside of register

    config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/octet-stream"));
    

提交回复
热议问题