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