Today we've encountered an EPiServer Find error which created 404 errors on certain areas of our site.This was caused because a user thrashed a few pages which were still referenced by a few products in EPiServer Commerse.
I don't think EPiServer should automatically remove content that is still referenced and should either log Errors or Warnings when the automatic thrash job is ran.Because now if at any point a user makes an error and the job is ran, the site is compromised.
In the version of Episerver CMS that I use, when an editor clicks Move to trash, they get notified "Any incoming links on the web to this page will not work after you move it to the trash." Are you saying that this warning is not adequate? Or are you saying that editors should not be permitted to delete content?
I understand that users get this notification, but humans make errors and I think having an automated job that knows no context shouldn't be responsible for permanently deleting this kind of content.
I'd like to see a warning so an admin or a developer can make an educated desiscion whether or not this content can be deleted permanently.
Just prevent editors from moving referenced content to the trash like this
public class PreventDeletingContentInitialization : IInitializableModule
private IContentEvents events;
private IContentRepository repository;
public void Initialize(InitializationEngine context)
this.events = context.Locate.Advanced.GetInstance<IContentEvents>();
this.repository = context.Locate.Advanced.GetInstance<IContentRepository>();
this.events.MovingContent += this.MovingContentToTrash;
public void Uninitialize(InitializationEngine context)
this.events.MovingContent -= this.MovingContentToTrash;
private void MovingContentToTrash(object sender, ContentEventArgs e)
List<ReferenceInformation> references = this.repository.GetReferencesToContent(
if (!references.Any() || e.TargetLink.ID != 2)
e.CancelAction = true;
e.CancelReason = "Deleting this content is not allowed, because it is still referenced.";
When a page is deleted, the change is not permanent. The page is moved to the trash container and can be restored by an authorized user.
Further, to prevent users from deleting content, remove their access rights to do that. Only give administrators permission to delete content.