New to Telerik UI for ASP.NET Core? Download free 30-day trial

Known Exceptions

This article provides solutions for some known exceptions you might encounter while working with the Telerik UI Grid component for ASP.NET Core.

Circular Reference Detected While Serializing an Object of Type

The reason for this exception is that the JavaScriptSerializer class used by the Json method cannot serialize object graphs which contain circular references (refer to each other).

Solution Use View Model objects and avoid serializing the properties which create the circular reference. For further information on this issue, refer to the article on avoiding circular reference exceptions.

JSON JavaScriptSerializer Serialization or Deserialization Error

This exception is thrown when the length of the JSON response exceeds the default MaxJsonLength.

Solution To fix this issue, use any of the following suggestions:

  • Enable paging by calling the Pageable method.
  • Serialize only the required properties of your model by using a View Model.
  • Manually serialize the DataSourceResult.

    public ActionResult Read([DataSourceRequest] DataSourceRequest request)
        var data = GetData();
        var serializer = new JavaScriptSerializer();
        var result = new ContentResult();
        serializer.MaxJsonLength = Int32.MaxValue; // Whatever max length you want here
        result.Content = serializer.Serialize(data.ToDataSourceResult(request));
        result.ContentType = "application/json";
        return result;

Sensitive Information Error Message

An exception that a request has been blocked because sensitive information could be disclosed to third-party web sites when this is used in a GET request would be thrown when the kendo.aspnetmvc.min.js is not included or is included before the kendo.all.min.js.

Yet another reason is that you explicitly specified that the Grid should make HTTP GET requests via the Type setting but did not allow HTTP GET requests.

Solution Allow GET requests

    // Omitted for brevity.
    .DataSource(dataSource => dataSource.Ajax()
        .Read(read => read.Action("Read", "Home").Type(HttpVerbs.Get)) // tell the DataSource to make GET requests
    // Omitted for brevity.

    // Omitted for brevity.
    <datasource page="0" type="DataSourceTagHelperType.Ajax" page-size="20" server-operation="false">
        <schema data="Data" total="Total" errors="Errors">
            <model id="ProductID"></model>
            <read url="@Url.Action("Read","Home")" type="Get" />
    // Omitted for brevity.

    public ActionResult Read([DataSourceRequest] DataSourceRequest request)
        var data = GetData();

        return Json(result.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);

Limited Usage of Templates

The Grid for Core is not rendered on the server. Therefore, it is not possible to define server-side templates (like Group Header Templates) which makes the usage of `.ServerOperations(true)` in this case incompatible.

Invalid Template Error When Nesting Client Templates

The Kendo UI widgets are unable to detect if they are used in nested client template scenarios. Such a setup requires the escaping of the # literals and the closing </script> tags in the HTML markup and JavaScript initialization statements of the nested widgets. However, this cannot happen automatically. As a result, nested client template scenarios are not supported out-of-the-box.

Cause Consider the following scenario:

  • Grid A is placed in a View. Grid A has a popup edit template.
  • Grid B is placed in a partial view, which represents the popup edit template of Grid A.
  • A Kendo UI widget C is placed in the same partial view as Grid B. The widget C belongs to the client detail template of the Grid B.

In the above scenario, the widget C will not be rendered correctly and will cause an Invalid template JavaScript error.

Solution To avoid the JavaScript error:

  1. Move the declaration of widget C to a separate partial view.
  2. Render the partial view in the main View where Grid A is defined. In this case widget C will not exist in a nested template context and its HTML/JavaScript output will not need any escaping.

See Also

In this article