Try our conversational search powered by Generative AI!

PageNotFoundException thrown by ClonedContentProvider when Deleting page in scheduled task



I'm trying to make a scheduled job that deletes all the job vanacies we have after the have expired or have been unpublished.

When i try to remove the pages eventually the ClonedContentProvider throws a PageNotFoundException when trying to clear the cache.

Example of what happens here:

I hope someone can help me out

foreach(VacancyDetailPage page in content)
                if(page != null)
                    if(page.EindDatum < DateTime.Today
                        || page.DatumExternExpiration < DateTime.Today
                        || page.StopPublish < DateTime.Today)
                        _contentRepository.Service.DeleteChildren(page.ContentLink, true, AccessLevel.FullAccess);
                        _contentRepository.Service.Delete(page.ContentLink, true, AccessLevel.FullAccess);

My gratitude in advance

[Pasting files is not allowed]

Edited, Jun 20, 2018 14:45

It would help if you can post the fullstacktrace here. Also ClonedContentProvider is not a framework classs, is it from Alloy?

Edited, Jun 20, 2018 14:53

Correction: the exception is indeed thrown by a a provider in a subproject which happens to be made by one of our past staff members. I'm able to resolve the issue.

Many thanks for your help!

The full stacktrace is:

StackTrace " at EPiServer.Core.Internal.DefaultContentLoader.Get[T](ContentReference contentLink, LoaderOptions loaderOptions)\r\n at EPiServer.Core.Internal.DefaultContentLoader.<GetAncestors>d__24.MoveNext()\r\n at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)\r\n at EPi.Cms.ContentProviders.ClonedContentProvider.ClearCache(Object sender, ContentEventArgs e) in C:\\Waternet-GIT\\waternet-global-waternet\\src\\backend\\EPi.Cms.ContentProviders\\ClonedContentProvider.cs:line 429\r\n at System.EventHandler`1.Invoke(Object sender, TEventArgs e)\r\n at EPiServer.Core.Internal.DefaultContentEvents.RaiseDeleteEvent(String key, DeleteContentEventArgs eventArgs)\r\n at EPiServer.Core.Internal.DefaultContentRepository.Delete(ContentReference contentLink, Boolean forceDelete, AccessLevel access)\r\n at Waternet.Global.Waternet.Vacancies.VacancyRemovalJob.UnpublishAndRemovedExpired(IEnumerable`1 content)\r\n at Waternet.Global.Waternet.Vacancies.VacancyRemovalJob.Execute()\r\n at EPiServer.Scheduler.Internal.DefaultScheduledJobExecutor.<Execute>d__31.MoveNext()" string

Edited, Jun 20, 2018 14:57

As you can see ClonedContentProvider is part of your project. It might be doing something wrong in ClearCache. If you want to find out you would have to post your code here.

But I can guess that it listens to Deleted event to clear cache. At that point getting the content is too late as it was deleted. If you want to clear the cache, you should listen to Deleting event instead 

Edited, Jun 20, 2018 15:00

Again, thank you very much. it did point me in the exact direction of where to look.

Jun 20, 2018 15:12
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.