Edit this page

Known Exceptions

Serialization

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

Below are listed some of the possible solutions for you to apply when resolving this issue.

  • Option 1 Enable paging by calling the Pageable method.

  • Option 2 Serialize only the required properties of your model by using a View Model.

  • Option 3 Manually serialize the DataSourceResult.

    Example
        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;
        }
    

Error Messages

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.

Example
// View

// 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.

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

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

Templates

Limited Usage of Templates

An exception that templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions can occur if an editable Grid is bound to a DataTable or DataSet. The reason is that the ASP.NET MVC EditorFor method does not support DataTable.

Solution

Use a pop-up edit form with a custom editor template.

For more information on how to resolve this issue, refer to the resources listed below.

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.

Solution

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.

The easiest way to avoid the JavaScript error is to:

  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

Other articles on the Kendo UI Grid for ASP.NET MVC:

Articles on Telerik UI for ASP.NET MVC:

Other articles on troubleshooting: