Copied to clipboard

Flag this post as spam?

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


  • Morten Ørgaard 22 posts 61 karma points
    Sep 10, 2016 @ 07:16
    Morten Ørgaard
    0

    IContentFinder not working on production server

    Hi

    I'm currently using Umbraco 7.4.3.

    I have the following:

    protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) 
    {
        ContentLastChanceFinderResolver.Current.SetFinder(new _404iLastChanceFinder());
        base.ApplicationStarting(umbracoApplication, applicationContext);
    }
    

    and

    public bool TryFindContent(PublishedContentRequest contentRequest)
    {
        if (contentRequest.Is404)
        {
            var root = contentRequest.RoutingContext.UmbracoContext.ContentCache.GetAtRoot().Single(x => x.DocumentTypeAlias == "domain");
            var notFoundNode = root.Children.Single(x => x.DocumentTypeAlias == "404ErrorPage");
    
            contentRequest.SetResponseStatus(404, "404 Page Not Found");
            contentRequest.PublishedContent = notFoundNode;
        }
    
        return contentRequest.PublishedContent != null;
    }
    

    On the production server, running IIS 7.5, it finds the proper nodes, but it displays the default .NET 404 error page and not the notFoundNode.

    On my developer machine with IIS Express it works as intended.

    Any help will be much appreciated.

    Best regards Morten

  • Marc Goodson 2148 posts 14352 karma points MVP 8x c-trib
    Sep 10, 2016 @ 11:39
    Marc Goodson
    101

    Hi Morten

    Have a look in your config/umbracosettings.config file on your production server and find:

      <web.routing
        trySkipIisCustomErrors="false"
        internalRedirectPreservesTemplate="false" disableAlternativeTemplates="false" disableFindContentByIdPath="false"
        umbracoApplicationUrl="">
      </web.routing>
    

    what is the value of trySkipIisCustomErrors ? set this to true, and it should IIS to 'back off' when serving 404 for your site...

  • Morten Ørgaard 22 posts 61 karma points
    Sep 10, 2016 @ 13:22
    Morten Ørgaard
    0

    Hi Marc

    Thank you very much, that was exactly what I needed.

  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    Sep 10, 2016 @ 12:06
    Sebastiaan Janssen
    1

    Pro tip: this is also part of one of the health checks, so if you're on 7.5+ you could easily see what you need to tweak on your live environment:

    enter image description here

  • Morten Ørgaard 22 posts 61 karma points
    Sep 10, 2016 @ 13:24
    Morten Ørgaard
    0

    Thanks for the tip, I will definitely be using health check when I start using 7.5+.

Please Sign in or register to post replies

Write your reply to:

Draft