Always have error “The ObjectContent 1 type failed to serialize the response body…”

后端 未结 4 460
再見小時候
再見小時候 2021-01-02 11:03

I use Web api to retrieve data from the database. I only have 1 table \"tblMessage\" and want to get data from that table.

I set everything up but then when I run th

4条回答
  •  生来不讨喜
    2021-01-02 11:51

    I had the same issue with Chrome, not so much with IE. In order to fix it I used the following lines at the Global.asax.cs, Application_Start() method:

    GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
    
    GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
    

提交回复
热议问题