2

I'm running into a weird issue with Sitecore 8.2 Update-6 where after I modify an item (with MVC controls) using the Sitecore Experience Editor I start getting NullReferenceExceptions when I view the page as a normal visitor.

My current Renderings for the item:

<r xmlns:p="p" xmlns:s="s" p:p="1">
  <d id="{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}">
    <r uid="{2D081E63-B246-4C1E-9CBD-404E3BB00206}">
      <p:d />
    </r>
    <r uid="{FAF13011-175F-4DCF-8356-337D848E1BC7}" p:after="*[1=2]" />
    <r uid="{05DD0AEC-B002-4835-9CDA-794DCA38B428}">
      <p:d />
    </r>
  </d>
</r>

Final renderings:

<r xmlns:p="p" xmlns:s="s" p:p="1">
  <d id="{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}">
    <r uid="{1F1726FC-D9F1-4735-8B04-5AF3F1876340}" p:before="*" s:ds="{3EA9EEA0-B852-4251-9B24-E7C6207C8FF4}" s:id="{CD37935F-BEEC-4435-9D0A-456E57928178}" s:ph="pageHeader" />
    <r uid="{9EC91D3C-60B0-46C3-8307-BEF51DE16483}" p:after="r[@uid='{1F1726FC-D9F1-4735-8B04-5AF3F1876340}']" s:ds="{BD389803-B963-469A-BBAB-6FC22AB10DE7}" s:id="{71FCA9EC-160E-4154-BA6E-C0ED4836896A}" s:ph="content" />
    <r uid="{EBA0DD59-A033-44AB-834A-8D2CD65B737D}" p:after="r[@uid='{9EC91D3C-60B0-46C3-8307-BEF51DE16483}']" s:ds="{70D7BE92-85BF-4AED-BB23-E8431EE4AB51}" s:id="{B46AD45F-383B-42CA-B416-A505773EC283}" s:ph="content" />
    <r uid="{894E47C8-0E09-4C74-8C36-A206FC15A92A}" s:ph="header" />
    <r uid="{65922EC1-EA0D-4EF1-A490-B17BE82A3711}" s:ph="footer" />
    <r uid="{3A88D3CC-26F8-4F6A-8D8C-B2A8788F2E47}" s:ph="placeholderBreadcrumb" />
    <r uid="{FAF13011-175F-4DCF-8356-337D848E1BC7}">
      <p:d />
    </r>
  </d>
</r>

I then get NullReferenceExceptions on the following three lines in my main layout (as I remove the placeholder code from the layout I can cycle through all three):

@Html.Sitecore().Placeholder("header")
@Html.Sitecore().Placeholder("placeholderBreadcrumb")
@Html.Sitecore().Placeholder("footer")

Despite seeing these errors, the page does work in the Experience Editor. However, before this I was running into an issue where the page would display when not logged in, but would throw exceptions on these same lines when trying to edit the page via the Experience Editor.

The header, placeholderBreadcrumb, and footer are not marked as Editable in Sitecore (defined in Layout > Placeholder Settings > Project > BusMain > ___).

The stack trace from the YSOD (which is essentially the same as what's in the Sitecore logs) is as follows:

[NullReferenceException: Object reference not set to an instance of an object.]
Sitecore.Mvc.Pipelines.Response.RenderPlaceholder.PerformRendering.CreateCyclePreventer(String placeholderName, Rendering rendering) +39
Sitecore.Mvc.Pipelines.Response.RenderPlaceholder.PerformRendering.Render(String placeholderName, TextWriter writer, RenderPlaceholderArgs args) +153
(Object , Object[] ) +73
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +474
Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +21
Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +194
Sitecore.Mvc.Helpers.SitecoreHelper.Placeholder(String placeholderName) +257
ASP._Page_Views_Project_BusMain_Layouts_Default_cshtml.Execute() in c:\path\to\Website\Views\Project\BusMain\Layouts\Default.cshtml:5 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +251
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +147
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +121
System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +135 Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +308

[InvalidOperationException: Error while rendering view: '/Views/Project/BusMain/Layouts/Default.cshtml' (model: 'Sitecore.Mvc.Presentation.RenderingModel, Sitecore.Mvc'). ]
Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +792 Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args) +147
Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Process(RenderRenderingArgs args) +75 (Object , Object[] ) +74
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +475
Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +195
Sitecore.Mvc.Presentation.RenderingView.Render(ViewContext viewContext, TextWriter writer) +331
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +375 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +88
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList
1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +831
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +831
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList
1 filters, ActionResult actionResult) +81
System.Web.Mvc.Async.<>c__DisplayClass21.b__1e(IAsyncResult asyncResult) +36

Pulling up ILSply suggests that it might be triggering off of Assert.IsNotNull(rendering, "rendering");, but I don't see why this would be the case.

The rendering in the header has no logic that would cause an exception, minus pulling in a view, with no logic, via Html.Partial(). The footer is the same, but the breadcrumbs does have logic that could potentially be throwing an exception. However, Sitecore getting stuck on the header and footer suggests this isn't the issue, as well as the fact that the page works in one display when it doesn't work in the other.

Any suggestions on how I can further troubleshoot the presentation details on this page?

EDIT:

Note that removing the header, footer, and placeholderBreadcrumb controls from the Final Renderings display allows the page to be viewed as a normal user, with the controls still visible.

However, once I go in and modify the item again via the Experience Editor the header, footer, and placeholderBreadcrumb items are added back in, with placeholder keys set accordingly, which then breaks the display.

  • I had same problem when I forgot to sync one of the rendering with TDS. So the rendering was in the Final Renderings of a page, but there was no such a rendering definition in that Sitecore instance. Make sure you published all the rendering definition items. – Marek Musielak Mar 1 '18 at 15:43
  • Good reminder. :) But yes, I did verify that everything is published, and other pages that use these components, but haven't been updated with the experience editor, also work. – James Skemp Mar 1 '18 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.