Geta / geta-notfoundhandler

The popular NotFound handler for ASP.NET Core and Optimizely, enabling better control over your 404 page in addition to allowing redirects for old URLs that no longer works.
Apache License 2.0
20 stars 16 forks source link

Do not create redirect for expired page #139

Open jonasboman opened 1 month ago

jonasboman commented 1 month ago

I am creating a scheduled job in optimizely cms 12, that should expire a page (based om some parameters) and also move the page. After that I wish to create a custom redirect to the old parent.

Having some issues with this.

It seems like NotFound has a Moved event hooked up that creates Redirects even on expired pages. When I use IRedirectService and AddOrUpdate method, it works, but I think the move-event (e g MovedContentRegistratorBackgroundService ) is lagging and overwrites the redirect I am creating.

Is there a way around this?

  1. Finding pages (with conditions)
  2. Iterate; Set page as expired, move to specifik page
  3. Create redirect: _redirectsService.DeleteByOldUrl(oldPageUrl); _redirectsService.AddOrUpdate(new CustomRedirect(oldPageUrl, parentPageUrl, true, RedirectType.Temporary));
jonasboman commented 1 month ago

@valdisiljuconoks do you have any input here? :)

jonasboman commented 1 month ago

Perhaps add logic in ContentUrlHistoryEvents to also take into consideration if the moved page is published or not. I guess I could use my own implementation of ContentUrlHistoryEvents. :)