This is a migrated thread and some comments may be shown as answers.

500 Internal Error

4 Answers 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Roy Wang
Top achievements
Rank 1
Roy Wang asked on 21 Jan 2010, 02:57 AM
Hi

I'm learning telerik MVC extensions from scratch now, from mocking the sample project downloaded with the source code. For the Gird control, everything is fine except for the ajax. When I enable ajax, sorting, paging all failed with a message box notifying 500 internal server error. I searched internet and also this forums, founding few hint to solve the problem, so I wrote this thread for help, to ensure whether some steps are missing.

--------------------------------------------------------------------------------------------
Update:
Okay, I see what happened at the server side. It is said that their is a A circular reference detected while serializing an object.

4 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 21 Jan 2010, 08:38 AM
Hi Roy Wang,

This means the objects you are trying to bind the grid to have a circular reference. Consider the following example:

public class Category
{
     public IList<Product> Products
     {
                get;
                set;
     }
}

public class Product
{
         public Category Category
         {
                get;
                set;
         }
}

In this case if you try to bind the grid to list of Category objects you will get the circular reference exception. This is due the fact that the built-in JavaScriptSerializer tries to serialize the Category object and then serializes its child Products. However since a Product has a reference to the Category (circular reference) the serializer fails with an exception. The solution is to either remove the circular reference property (in this case that would mean to remove the Category property from the Product object) or user ViewModel objects for databinding (the recommended approach). You can check this blog post for more info.

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Roy Wang
Top achievements
Rank 1
answered on 25 Jan 2010, 06:41 AM
Thanks for reply so soon, Korchev. I solve the problem by hacking the edmx file generated by EFv1 designer.

But I doubt about using ViewModels(When you refer to POCO class) with EFv1 because the sorting and filtering features will use construct linq to Entity/POCO queries which is not easy to do with EFv1.

Another problem I encountered is I can't sort/filter data in memory, such as List or Dictionary. Is there any documentation on how to query those objects? Thanks!
0
Atanas Korchev
Telerik team
answered on 25 Jan 2010, 08:09 AM
Hi Roy Wang,

I am sorry but I cannot understand your question. What do you mean by sorting objects in memory?
We have something similar exposed in our editing demo - the data comes from an object collection stored in the session. Is this what you are looking for?

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Roy Wang
Top achievements
Rank 1
answered on 25 Jan 2010, 10:09 AM
Hi Korchev,

Yes, exactly what I want, done with my code. The mvc extension is super cool!
Tags
Grid
Asked by
Roy Wang
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Roy Wang
Top achievements
Rank 1
Share this question
or