Copied to clipboard

Flag this post as spam?

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


  • Gareth Wright 32 posts 101 karma points c-trib
    Mar 04, 2020 @ 09:53
    Gareth Wright
    0

    LastChanceContentFinder

    Hi Richard,

    Is it possible in Umbraco 8, SEO Checker 2.9, to have your own custom LastChanceContentFinder.

    We need to be able to handle this ourselves, rather than SEO checker. However it seems to be taking control of this if URL redirecting is enabled.

    Could you advise.

    Thanks again, Gareth

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Mar 04, 2020 @ 09:57
    Richard Soeteman
    0

    At the moment not. For the same reason You need it, SEOChecker needs to determine the 404. To bad you can only have one LastContentFinder in Umbraco. You can replace mine.

  • Gareth Wright 32 posts 101 karma points c-trib
    Mar 04, 2020 @ 09:58
    Gareth Wright
    0

    Would this work? or would you need to remove yours?

    RuntimeLevel(MinLevel = RuntimeLevel.Run)]
    public class LastChanceContentFinderComposer : IUserComposer
    {
        public void Compose(Composition composition)
        {
            composition.SetContentLastChanceFinder<LastChanceContentFinder>();
        }
    }
    
  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Mar 04, 2020 @ 11:37
    Richard Soeteman
    0

    Not Sure but best to remove mine I guess Otherwise it's first one wins.

  • Thomas 1 post 72 karma points
    Aug 31, 2020 @ 10:43
    Thomas
    1

    Hi Gareth,

    We managed to get this to work.

    First you need to make sure that your custom content finder is registered after the SEO one. Do this by using the ComposeAfter attribute on the composer where you register your own custom content finder.

    [ComposeAfter(typeof(SEOCheckerComposer))]
    public class NotFoundComposer : IUserComposer
    {
        public void Compose(Composition composition)
        {
            // We need the SEO Redirect Content Finder in our custom 
            // content finder. So register the RedirectContentFinder.
            composition.Register<RedirectContentFinder>();
            composition.SetContentLastChanceFinder<Error404ContentFinder>();
        }
    }
    

    In your custom Content Finder, inject the RedirectContentFinder and check if it finds something to redirect first. If not, then apply your own logic.

    private readonly RedirectContentFinder redirectContentFinder;
    
    public Error404ContentFinder(RedirectContentFinder redirectContentFinder)
    {
        this.redirectContentFinder = redirectContentFinder;
    }
    
    public bool TryFindContent(PublishedRequest request)
    {
        if (redirectContentFinder.TryFindContent(request))
        {
            return true;
        }
    
        // Your custom 404 logic
    
        // Return true or false depending on whether our custom 404 page was found
        return request.PublishedContent != null;
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft