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

[Solved] Telerik MVC Grid with error "The requested URL did not return JSON"

3 Answers 235 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.
zorro
Top achievements
Rank 1
zorro asked on 08 Feb 2010, 07:21 AM
Hi everybody,

In my current project, I am using MVC 2 RC with Telerik Extension for MVC 2 build version 2009.3.1218, Linq2SQL. Followed by the document guide, I used Ajax Binding but when I changed to another page or pressed "refresh" button, the error dialog occured with the message "Error! The requested URL did not return JSON".

Kindly help me to fix it. I try have being searched for 3 days on google but I found nothing helpful.

The code is attached, you much change connection string in Web.config before run.


Thanks all.


3 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 08 Feb 2010, 10:33 AM
Hello Kim,

After further investigation of the depicted erroneous behavior, we find out that the reason of the problem is a "circular reference" exception. Linq2Sql provides lazy loading, which causes circular references. MS JSON serializer is not able to serialize circular reference and throws exception.

To fix this problem you need to remove lazy loading and child properties of the auto-generated by Linq2Sql classes.

All the best,
Georgi Krustev
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
zorro
Top achievements
Rank 1
answered on 08 Feb 2010, 05:23 PM
HIi Krustev,

Thanks for your reply, I solved this problem for Linq2Sql. But in case I use NHibernate and FluentNHibernate to write mapping class. I have still met this problem although I disabled Lazy Load function. How can I solve it? 

Regards,
Kim.
0
Atanas Korchev
Telerik team
answered on 08 Feb 2010, 05:42 PM
Hello zorro,

I have a blog post discussing this problem. The second solution (using ViewModel objects) should work for NHibernate as well.

All the best,
Atanas Korchev
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Grid
Asked by
zorro
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
zorro
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or