Q:

Get Critical error during Json request using Kendo UI

I have a problem. In my company I need to try out how Angular.js works together with ASP.NET MVC. Now I want to create a simple little application. On the front page there is a view with a Kendo UI grid. Inside my App.js file I read data from my Data Controller. The Controller Action gets called but as soon as the  code is done executing I get the following error:

Here is the rest of my Code:
Controller:
[HttpGet]
public JsonResult GetEmergencyRegions([DataSourceRequest]DataSourceRequest request, string searchterm)
{
    var emergencyRegions = _repository.GetEmergencyRegionBySearchTerm(searchterm);
    return Json(emergencyRegions.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}

App.js
$scope.gridOptions = {
    columns: [{
        field: "Description",
        title: "Beschreibung"
    }, {
        field: "Region",
        title: "Region"
    }, {
        field: "Phone",
        title: "Telefon"
    }, {
        field: "HasPointOfSale",
        title: "PoS"
    }],
    pageable: true,
    dataSource: {
        pageSize: 5,
        transport: {
            read: function (e) {
                $http.jsonp('/Data/GetEmergencyRegions')
                  .then(function success(response) {
                      e.success(response.data);
                  }, function error(response) {
                      alert('something went wrong')
                      console.log(response);
                  })
            }
        }
    }
};

View with the Grid
<kendo-grid options="gridOptions">

</kendo-grid>

On Stackoverflow I already found something with adding ?callback=JSON_CALLBACK to the jsonp URL but it didn't help.
Notice
When I remove the JsonRequestBehavior.AllowGet inside my Controller, I don't get the error but then I get the status Code 404.

A:

Found the solution.
There were several things to change:

Remove DataSourceRequest part in Controller. With this change the critical JavaScript error disapears.
public JsonResult GetEmergencyRegions(string searchterm)
{
    var emergencyRegions = _repository.GetEmergencyRegionBySearchTerm(searchterm);
    return Json(emergencyRegions, JsonRequestBehavior.AllowGet);
}

I now had a 404 error again in my App.js. Solution for that is changing jsonp to get.  I found this solution in the following link: AngularJS: how to make a jsonp request
read: function (e) {
     $http.get('/Data/GetEmergencyRegions?callback=JSON_CALLBACK')
         .then(function success(response) {
              e.success(response.data);
          }, function error(response) {
              alert('something went wrong')
              console.log(response);
     })
}

Run the Solution and be Happy :-)

