page builder error

lawrence whittemore asked on June 4, 2021 14:13

I am getting an error when trying to load a page. This error is

System.NullReferenceException: 'Object reference not set to an instance of an object.'

It is being thrown here @await Html.Kentico().EditableAreaAsync("area1")

If I create a new page the page shows, If I save it again whether i add anything to the page builder or not I get that error.

this is the full stack trace

Exception type: System.NullReferenceException Stack trace: at Kentico.PageBuilder.Web.Mvc.HtmlHelperExtensions.PropagateCacheOptions(IPageBuilderDataContext dataContext, String areaIdentifier, EditableAreaOptions options) at Kentico.PageBuilder.Web.Mvc.HtmlHelperExtensions.EditableAreaCore(HtmlHelperExtensionPoint htmlHelper, String areaIdentifier, EditableAreaOptions options) at Kentico.PageBuilder.Web.Mvc.HtmlHelperExtensions.EditableAreaAsync(HtmlHelperExtensionPoint htmlHelper, String areaIdentifier, EditableAreaOptions options) at AspNetCore.Views_Shared_PageTypes_NLH_Home.ExecuteAsync() in C:\Users\ahlnw1\source\repos\IntranetCore3\Kentico13\Intranet2021\Views\Shared\PageTypes\NLH_Home.cshtml:line 14 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, Nullable1 statusCode) at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable1 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.Infrastructure.ResourceInvoker.g__Awaited|29_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) at Kentico.Content.Web.Mvc.ContentOutputMiddleware.InvokeAsync(HttpContext context) at Kentico.Web.Mvc.KenticoRequestLocalizationMiddleware.InvokeAsync(HttpContext context) at Kentico.Content.Web.Mvc.PageRedirectionContextMiddleware.InvokeAsync(HttpContext context) at Kentico.Web.Mvc.KenticoRequestEventsMiddleware.InvokeAsync(HttpContext context) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Recent Answers


lawrence whittemore answered on June 7, 2021 15:58

I have no idea why this switch mattered, but using the tag helpers fixed my issue.

changed to this... <editable-area area-identifier="area1" />

instead of this. @await Html.Kentico().EditableAreaAsync("area1")

If someone knows why that made a difference, I am all ears.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.