7

I have a strange situation where I get a 'Item not found' on postback in Experience Editor when I edit an page.

The culprit is a controller rendering which has a line of code in to get the current page item using Glass:

ContentBase pageHeading = GetDataSourceItem<ContentBase>();

On initial load of the page in Experience Editor the Page Heading item is resolved correctly and populated. However after editing the title of the page and saving, if I debug I can see pageHeading has resolved to our custom 404 page - set in:

<setting name="ItemNotFoundUrl" value="page-not-found.aspx"/>

The controller therefore returns the page not found at the bottom of the controller and instead of reloading my current page (with the updated heading) in Experience Editor it loads the page not found page, as pageHeading below has resolved to the page-not-found page:

return PartialView("~/Views/GoAhead/Partials/_PageHeading.cshtml", pageHeading);

The other result of this is that the Final Renderings on the page I was editing get blitzed. I have to go and reset the layout on my page to get them back.

I can't figure out what is causing it and annoyingly if I copy the controller rending in Sitecore and point it at the same controller code it works fine. It's just this PageHeading controller rendering that causes this. This suggests the issue is somehow related to the PageHeading controller rendering item and not the code. I've compared it with my copy of the controller rendering item and it seems the same and that works fine.

Further info: Sitecore 8.1 Update 2, Sitecore MVC, Glass

  • 1
    Provided copy of your PageHeading controller, also provide code for GetDataSourceItem method. – Sergey Kravchenko Oct 13 '16 at 9:20
10

So it's took me all of yesterday and most of today to figure this out. In the end it was nothing to do with my code or configuration at all. The log files showing some errors were a Red-Herring and leading me in the wrong direction.

It is a Sitecore bug with 8.1 Update-2 (public reference: 108023).

This blog post was really useful for identifying it:

http://www.sitecorecoffee.com/2016/06/issue-with-final-layout-and-experience.html

You can download the Sitecore Hotfix from here: http://54.86.191.98/Sitecore108023-RenderingsHotfix.zip

provided by Thomas Eldblom on Github who got it from Sitecore.

Once I did this my pages saved fine and updated as expected in Experience Editor.

To apply the hotfix just include the dll in the zip folder in your solution and drop the config file in /app_config/ which patches the pipeline in from the dll.

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set">
  <sitecore> 
    <sitecore.experienceeditor.speak.requests>
      <request name="ExperienceEditor.Save.CallServerSavePipeline" type="Sitecore.ExperienceEditor.Speak.Ribbon.Requests.SaveItem.CallServerSavePipeline, Sitecore.ExperienceEditor.Speak.Ribbon">
        <patch:attribute name="type">Sitecore.Support.ExperienceEditor.Speak.Ribbon.Requests.SaveItem.CallServerSavePipeline, Sitecore.Support.108023</patch:attribute>
      </request>
    </sitecore.experienceeditor.speak.requests>  
  </sitecore>
</configuration>

Other errors people may search for are:

layout for the requested document was not found

and:

Final renderings lost/erased when saving in Experience Editor

There is further information on this here also:

https://github.com/Sitecore/Habitat/issues/136

Hopefully this will help anyone else coming across this issue.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.