Sitecore version: 8.1 update 3.

Whenever I try to delete an item in the Experience Editor, I get a browser prompt in the page ("Leave site? Changes you made may not be saved.") and if I confirm it, I am sent to the 500 error page and the below error is logged.

6648 09:39:24 ERROR Application error.
Exception: System.Web.HttpUnhandledException
Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.
Source: System.Web
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Nested Exception

Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Sitecore.Web.UI.Sheer.ClientPage.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Nested Exception

Exception: System.InvalidOperationException
Message: The Sitecore.Client.ContentDatabase is null.
Source: Sitecore.Kernel
   at Sitecore.Client.get_ContentDatabase()
   at Sitecore.Shell.Applications.ShellForm.RefreshLinks(Control parent)
   at Sitecore.Shell.Applications.ShellForm.OnLoad(EventArgs e)

Anyone seen this or have any ideas how to fix it?

  • Have you switched from on Sitecore Desktop to some other database in another tab (core/web)? Was there any code/config change that caused the issue? – Marek Musielak Dec 10 '18 at 15:30
  • Haven't switched databases somewhere else in the session (I can open it in EE and immediately delete it without changing anything and the problem happens). No recent config change that seems relevant. – Dan Sinclair Dec 10 '18 at 15:32
  • Which Sitecore version exactly is this happening? Can you disable all custom configs and try again? Are you logged in as admin? – Peter Procházka Dec 11 '18 at 5:01

This was a strange one. It was our own custom code that caused it, but it's possible someone could run into a similar issue so I'll add my findings here.

Relevant context

  • We have an item:deleted event handler for pages that also deletes a corresponding item in a data folder.
  • We have applied Sitecore's 321270.321271.103751 hotfix which updates the \sitecore\shell\Applications\WebEdit\WebEditRibbon.aspx file (used for the ribbon in the Experience Editor) and also the referenced Sitecore.Support.Shell.Applications.WebEdit.WebEditRibbonForm.
    • This change involves checking the site of current item to ensure links are generated properly
  • The WebEditRibbonForm class has a DeletedNotification(object sender, ItemDeletedEventArgs args) method that is called for each item that's deleted which, in our case, was first the page and then the page's data folder.
  • This DeletedNotification(...) method saves the ID of the parent of the item that was deleted so that, when the time comes, it could be redirected to

What was happening?

So here's how it was happening that wasn't working:

  1. User clicks delete in Experience Editor
  2. WebEditRibbonForm receives DeletedNotification for page, saves parent ID of the page into parentID private field
  3. WebEditRibbonForm receives DeletedNotification for page's data folder, saves parent ID of the page's data folder into the parentID private field
  4. Deletions complete successfully
  5. WebEditRibbonForm receives call to Redirect() method, which needs to respond with the URL to the page to load next (the parent of the deleted item is expected)
  6. WebEditRibbonForm uses the parentID private field to look for the item and checks to see if it or any of its parents have layout details
  7. They don't (because the parentID is in the data area, not a page), so it returns an invalid link
  8. The page tries to redirect, but at the destination receives the error from the question

To fix it, I applied the following changes:

Updated WebEditRibbonForm

Create a custom WebEditRibbonForm with a simple change:

public class CustomWebEditRibbonForm : Sitecore.Support.Shell.Applications.WebEdit.WebEditRibbonForm
    protected override void DeletedNotification(object sender, ItemDeletedEventArgs args)
        // Only save the parent ID for redirection if this is a deletion notification for a page
        if (args.Item.IsDerived(new ID("ID-OF-BASE-PAGE-TEMPLATE")))
            base.DeletedNotification(sender, args); 

Updated WebEditRibbon.aspx

Update the CodeBeside to use the custom WebEditRibbonForm

<sc:CodeBeside runat="server" Type="Custom.CustomWebEditRibbonForm,Custom" />
| improve this answer | |

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.