ASP.NET Web API: Non-descriptive 500 Internal Server Error

前端 未结 10 1281
难免孤独
难免孤独 2020-12-07 16:08

As title says, I’ve got 500 Internal Server Error from GET request to an IQueryable action. The body of the error is empty. That error happens after my action returns result

10条回答
  •  猫巷女王i
    2020-12-07 17:08

    This may be related to circular reference.

    http://www.asp.net/web-api/overview/formats-and-model-binding/json-and-xml-serialization#handling_circular_object_references

    Try adding the following code to Application_Start method in the Global.asax file:

     var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
     json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.All;
    

提交回复
热议问题