Copied to clipboard

Flag this post as spam?

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


  • OleP 56 posts 239 karma points
    Dec 12, 2019 @ 14:53
    OleP
    0

    Trigger chosen 404 page from RenderMvcController

    Hi Richard

    I'm doing a project where a part of the content comes from a custom table, and I use a RenderMvcController to fetch the content from the custom table and return it to the view.

    If the requested content does not exist, I return HttpNotFound(). This gives me the default IIS 404 page. If I remove the chosen 404 page from SEOChecker, I get the default Umbraco 404 page.

    Alternativly, can I disable the 404 handler in SEOChecker, and use the 404 section in umbracoSettings.config?

    Thanks!

  • Richard Soeteman 3722 posts 11521 karma points MVP
    Dec 12, 2019 @ 15:26
    Richard Soeteman
    0

    Hi Ole,

    You could disable the whole 404 module but then it will also not track not found url's anymore. But good option to add for a future release. What version are you on? I am finalizing 2.9 that works on Umbracov8+ and would be nice if it can be disabled but doesn't it pickup the Umbraco page at all when configured?

    Best,

    Richard

  • OleP 56 posts 239 karma points
    Dec 12, 2019 @ 19:54
    OleP
    0

    Hi Richard,

    The normal Umbraco pages are picking up the 404 page set in SEOChecker just fine. It's only the custom pages causing trouble.

    I'm on Umbraco 8 and SEOChecker 2.8.2.

    I tried to add my own NotFoundHandler according to this documentation https://our.umbraco.com/Documentation/Reference/routing/request-pipeline/IContentFinder#notfoundhandlers , but it doesn't get hit at all when I debug.

    Tracking of not found url's is a really helpful feature, so I'd rather not lose out on it.

    Please tell me how I can assist you in narrowing down the issue.

  • Richard Soeteman 3722 posts 11521 karma points MVP
    Dec 13, 2019 @ 07:49
    Richard Soeteman
    0

    Hi Ole,

    Add the following attribute to your class and it should be ok to render your 404 page. But that will also replace my 404 handling

    [ComposeAfter(typeof(SEOChecker.Core.ContentFinder.RedirectContentFinder))]
    

    But I need to add the feature to disable 404 rendering in a next release.

    Best,

    Richard

  • OleP 56 posts 239 karma points
    Dec 13, 2019 @ 09:56
    OleP
    0

    Hi Richard,

    The attribute does make my own LastChanceFinder get hit. But the 404 page is still the default Umbraco one: enter image description here

    This is my current implementation of the LastChanceFinder:

    [ComposeAfter(typeof(SEOChecker.Core.ContentFinder.RedirectContentFinder))]
        public class LastChanceFinder : IContentLastChanceFinder
        {
            bool IContentFinder.TryFindContent(PublishedRequest request)
            {
                IPublishedContent notFoundNode = request.UmbracoContext.Content.GetById(new Guid("943bd6bb-c0fa-4a16-b305-778955f5403a"));
    
                if (notFoundNode != null)
                {
                    request.PublishedContent = notFoundNode;
                }
    
                return request.PublishedContent != null;
            }
        }
    

    And I register it in my composer like this: composition.SetContentLastChanceFinder<LastChanceFinder>();

  • Richard Soeteman 3722 posts 11521 karma points MVP
    Dec 13, 2019 @ 10:03
    Richard Soeteman
    0

    I will see If I can implement the disable 404 shortly

  • OleP 56 posts 239 karma points
    Dec 13, 2019 @ 12:21
    OleP
    0

    But like you said, that will also disable the tracking of 404 errors? That is not what I want.

    Am I raising the 404 error correctly by using return HttpNotFound() in a RenderMvcController?

    This is the first time I'm working with custom data using NPoco, so I want to make sure the error is not on my end :)

  • Richard Soeteman 3722 posts 11521 karma points MVP
    Dec 13, 2019 @ 12:25
    Richard Soeteman
    0

    Hi Ole,

    I am going to make an option that only disables 404 rendering not the rest.

    Best,

    Richard

  • OleP 56 posts 239 karma points
    Dec 13, 2019 @ 12:39
    OleP
    0

    enter image description here

  • Richard Soeteman 3722 posts 11521 karma points MVP
    Dec 18, 2019 @ 09:45
    Richard Soeteman
    100

    Hi Ole,

    Some further tests before an official release but this version should respect your Umbraco 404 collection. It's not possible to disable all functionality otherwise the language specific redirects will no longer work but this version should respect the 404 collection in UmbracoSettings again so you can use that again.

    https://www.dropbox.com/s/1dwjnsj84y5bw2y/seo-checker29_0.zip?dl=0 Best,

    Richard

  • OleP 56 posts 239 karma points
    Jan 06, 2020 @ 10:17
    OleP
    0

    Hi Richard

    I finally got around to test your build. The 404 collection in UmbracoSettings are now respected, but it doesn't solve my issue when returning HttpNotFound() in my route hijacking controller. Neither the default Umbraco 404 page or my LastChanceHandleris used. However this actually does not appear to be a SeoChecker issue. Same behavior appears if I remove the SEOChecker package.

Please Sign in or register to post replies

Write your reply to:

Draft