Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Malthe Petersen 35 posts 211 karma points c-trib
    Sep 30, 2019 @ 11:33
    Malthe Petersen

    Hi Umbraco Forum.

    Is there any events for the Redirect service? So we can subscribe to for example Register/Delete?

    Regards Malthe

  • Steve Megson 148 posts 940 karma points MVP c-trib
    Sep 30, 2019 @ 14:29
    Steve Megson

    The Redirect service doesn't currently expose any events.

    A Registered event should be simple to add, though I'd be wary of doing too much work in your event handler because you could make it very expensive to rename a page with many descendants.

    A Deleted event would add some overhead because it would need to fetch the details from the database. That's not a big deal when deleting a single redirect from the dashboard, though.

    The awkward part would be if you need to know about redirects being deleted when content is deleted. Although the service has a DeleteContentRedirectUrls method, it's not used when content is being deleted. The ContentService deals with deleting the affected redirects itself.

  • Malthe Petersen 35 posts 211 karma points c-trib
    Sep 30, 2019 @ 16:47
    Malthe Petersen

    Hi Steve.

    Thank you for your very awesome answer. :-)

    So I have been digging a little through the deleting of content in the code. Design wise it seems incorrect that the RedirectUrlService doesn't take care of handling deletions. For example if we were to make a cache decorator around the redirects, we wouldn't be able to do that - which is quite annoying. Not that i am trying to achieve that right now.

    So I assume it is done by a SQL GetDeleteClauses() (DocumentRepository.cs, line 188) because it should be easier to read and everything concerning the specific piece of content would be deleted.

    I agree with you that it is going to be difficult to raise an event when multiple redirects are being deleted.

    Do you know whether this part of the code is something that is being refactored for v9?

Please Sign in or register to post replies

Write your reply to: