Click here to Skip to main content
16,004,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

Requirement is like i wanted to send the result of a MVC web api to client side via some js code. But the Get api is returning a list of complex type.
C#
public class WhitepapersController : ApiController
{
// GET /whitepapers
[WebApiOutputCache(120, 60, false)]
public IQueryable<filteredwhitepaperlist_result> Get()
{
using (var rep = new WhitepaperRepository())
{
var lstWp = rep.GetPagedFilteredWhitepapers(1, 20, "newest"); // this return list of Complex type "FilteredWhitepaperList_Result"
return lstWp.AsQueryable();
}
}

The error stated like:
Complex type cannot be serialized to JSON because its IsReference setting is 'True'. The JSON format does not support references because there is no standardized format for representing references. To enable serialization, disable the IsReference setting on the type or an appropriate parent class of the type.
at System.Runtime.Serialization.Json.DataContractJsonSerializer.CheckIfTypeIsReference(DataContract dataContract)
at System.Runtime.Serialization.Json.XmlObjectSerializerWriteContextComplexJson.GetDataContract(Int32 id, RuntimeTypeHandle typeHandle)



Somebody having something on this?

Please help

Thanks.
Posted
Updated 12-Jun-12 5:35am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900