I have just started a new contract and althought I am used to using Kendo, this is my first experience using Kendo Core.
Typically I would have my controller, and my action and bind on this using
.DataSource(ds => ds.Read(r => r.Action("RefreshRecommendationGridData", "ReportLookup")))
However the firm that I am at heavily uses routing
[Authorize]
[Route("report-lookups")]
public class ReportLookupController : Controller
{
[AccessRights("Lists")]
[HttpPost]
[Route("report-lesson-recommendations/manage")]
public async Task<IActionResult> RefreshRecommendationGridData([DataSourceRequest] DataSourceRequest request)
{
var result = await _cacheService.SearchForReportLessonRecommendationsAsync(null);
return Json(result.ToDataSourceResult(request));
}
}
When attempting this and looking through developer tools and the network and when using
.DataSource(ds => ds.Read(r => r.Url("manage"))
I get a 400 Bad Reqest error.
I guess I am missing something, however what that is I am at a complete loss. I suspect its something quite simple, however, I cannot find anything on Telerik site that will help.
If I change this to a [HttpGet]
then this is returned as a 404 error.
I have tried the most basic of calls in a new controller with no routing and as per a vanilla example, however I get the same results.
I have found my answer, and albeit through a lot of stubling in the dark and no use or valuable response from Telerik themselves.
.Read(r => r.Action("RefreshRecommendationGridData", "ReportLookup").Data("sendAntiForgery"))
and then in the javascript
function sendAntiForgery() {
return { "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val() }
}