Ошибка пользовательского интерфейса Kendo System.NullReferenceException в .NET Core 2.0 - PullRequest
0 голосов
/ 11 сентября 2018

Я недавно использую Kendo.Mvc для моего проекта.Я использую Kendo.Mvc v2016.2.616 от NuGet

Но при его использовании выдается ошибка.

Вот мой .cshtml файл

@(Html.Kendo().Grid<TestViewModel>()
    .Name("TestGrid")
    .Columns(columns =>
    {
        columns.Bound(x => x.Id).Hidden(true);
        columns.Bound(x => x.SomeString).Width(480);
        columns.Bound(x => x.SomeBigInt).Width(100);
        columns.Bound(x => x.SomeDate).Width(200);
    })
    .Scrollable()
    .Sortable()
    .Pageable(pageable => pageable
        .Refresh(true)
        .PageSizes(new int[] { 10, 20, 40, 60, 80, 100 })
        .ButtonCount(6))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("GetGridData", "Test"))
        .PageSize(20)
    )
)

здесь мойController

Public class TestController : Controller
{
    public IActionResult GetGridData([DataSourceRequest]DataSourceRequest request)
    {
        return Json(service.GetGridData(request));
    }
}

Я уже добавляю ссылку в _ViewImports.cshtml и _ViewStart.cshtml следующим образом:

_ViewImports.cshtml

@using Web
@using Application.ViewModels
@using Kendo.Mvc.UI
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Kendo.Mvc

_ViewStart.cshtml

@{
    Layout = "_Layout";
}
@using Kendo.Mvc.UI;

А вот и трассировка стека

System.NullReferenceException: Object reference not set to an instance of an object.
   at Kendo.Mvc.UI.Fluent.CrudOperationBuilderBase`1.Action(String actionName, String controllerName, Object routeValues)
   at AspNetCore.Views_Test_Index.<>c.<ExecuteAsync>b__0_7(CrudOperationBuilder read) in Path\Index.cshtml:line 29
   at Kendo.Mvc.UI.Fluent.AjaxDataSourceBuilderBase`2.Read(Action`1 configurator)
   at AspNetCore.Views_Test_Index.<>c.<ExecuteAsync>b__0_2(DataSourceBuilder`1 dataSource) in Path\Index.cshtml:line 27
   at Kendo.Mvc.UI.Fluent.GridBuilder`1.DataSource(Action`1 configurator)
   at AspNetCore.Views_Test_Index.ExecuteAsync() in Path\Index.cshtml:line 12
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
   at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ActionContext actionContext, IView view, ViewDataDictionary viewData, ITempDataDictionary tempData, String contentType, Nullable`1 statusCode)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
   at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult result)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResultFilterAsync[TFilter,TFilterAsync]()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultFilters()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Спасибо, прежде чем

...