diff --git a/src/Umbraco.Infrastructure/Routing/RedirectTrackingComponent.cs b/src/Umbraco.Infrastructure/Routing/RedirectTrackingComponent.cs index 7fecba7c78..84f0ccdabd 100644 --- a/src/Umbraco.Infrastructure/Routing/RedirectTrackingComponent.cs +++ b/src/Umbraco.Infrastructure/Routing/RedirectTrackingComponent.cs @@ -40,9 +40,6 @@ namespace Umbraco.Web.Routing public void Initialize() { - // don't let the event handlers kick in if Redirect Tracking is turned off in the config - if (_webRoutingSettings.DisableRedirectUrlTracking) return; - ContentService.Publishing += ContentService_Publishing; ContentService.Published += ContentService_Published; ContentService.Moving += ContentService_Moving; @@ -66,6 +63,9 @@ namespace Umbraco.Web.Routing private void ContentService_Publishing(IContentService sender, PublishEventArgs args) { + // don't let the event handlers kick in if Redirect Tracking is turned off in the config + if (_webRoutingSettings.DisableRedirectUrlTracking) return; + var oldRoutes = GetOldRoutes(args.EventState); foreach (var entity in args.PublishedEntities) { @@ -75,12 +75,18 @@ namespace Umbraco.Web.Routing private void ContentService_Published(IContentService sender, ContentPublishedEventArgs args) { + // don't let the event handlers kick in if Redirect Tracking is turned off in the config + if (_webRoutingSettings.DisableRedirectUrlTracking) return; + var oldRoutes = GetOldRoutes(args.EventState); CreateRedirects(oldRoutes); } private void ContentService_Moving(IContentService sender, MoveEventArgs args) { + // don't let the event handlers kick in if Redirect Tracking is turned off in the config + if (_webRoutingSettings.DisableRedirectUrlTracking) return; + var oldRoutes = GetOldRoutes(args.EventState); foreach (var info in args.MoveInfoCollection) { @@ -90,6 +96,9 @@ namespace Umbraco.Web.Routing private void ContentService_Moved(IContentService sender, MoveEventArgs args) { + // don't let the event handlers kick in if Redirect Tracking is turned off in the config + if (_webRoutingSettings.DisableRedirectUrlTracking) return; + var oldRoutes = GetOldRoutes(args.EventState); CreateRedirects(oldRoutes); }