Copied to clipboard

Flag this post as spam?

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


  • Bruce Newton 8 posts 42 karma points
    Sep 10, 2013 @ 07:36
    Bruce Newton
    0

    Redirection problems involving unpublished content

    Hi Stefan,

    I've been doing some testing of our Umbraco 6.1.5 site with the current Url tracker version 2.2.3 and have come up with a couple of issues with the url tracker.  Our users have a policy of unpublishing content rather than deleting it (since it is sometimes reused at a later date) so these are the sorts of things they will be doing:

    * If you move a published node, then unpublish it, then try to visit the original node url, a blank page is presented in the browser (chrome), rather than receiving a 410 Gone (or i would actually prefer to receive a 404 - see below).  Further investigation shows that the url tracker code is returning a 301 redirect response, however without a url to redirect to.

    * If you unpublish a node, then re-publish it, then move it, requests to the original url receive a 410 Gone response, rather than being redirected to the new node url location.  Further investigation shows that a redirect entry for the move is not created in the url tracker table, and the 410 entry remains in the table (against the original location of the node).

    We actually don't want to send 410 Gone responses, but to treat deleted nodes simply as not found content (with our standard 404 error page that provides options to search for content on the site).  Do you know of any way to accomplish this with the current version of the URL tracker, or would it be possible to include an additional setting that allows 410 Gone to be ignored (ie. to perform standard 404 processing instead of responding with 410)?

    Thanks,

    Bruce.

  • Stefan Kip 1606 posts 4098 karma points c-trib
    Sep 10, 2013 @ 10:09
    Stefan Kip
    0

    Thanks for the feedback Bruce, I'll look into it in the future.
    There is no setting (yet) to disable the 410 Gone behavior, but maybe you could use IIS configuration to show your 404 page when a 410 status code is returned? (http://www.iis.net/configreference/system.webserver/httperrors)

  • Bruce Newton 8 posts 42 karma points
    Sep 11, 2013 @ 06:07
    Bruce Newton
    0

    Thanks for the advice Stefan.  

    I've tried playing with the IIS config but can't quite get the behaviour that we require.  

    As a temporary solution, i've discovered that if i comment out the subscription of the content_BeforeClearDocumentCache event handler in your code (so that 410 entries are not created in our database) then we seem to get the redirection and 404 handling that we want (further testing required, but so far so good).  We can revert back to your packaged version if/when you have time to update it.  Thanks.

  • Simon Dingley 1431 posts 3332 karma points c-trib
    Sep 01, 2015 @ 11:41
    Simon Dingley
    0

    @kipusoep Is it now possible to control when a 410 is returned instead of a 404 for unpublished content? Ideally it would also be good to have the ability to return the 404 page for those requests with a 410 response but unfortunately your solution won't work in our case where we have a multi-site install and each language has it's own 404.

  • Stefan Kip 1606 posts 4098 karma points c-trib
    Sep 01, 2015 @ 11:53
    Stefan Kip
    0

    @Simon

    "Is it now possible to control when a 410 is returned instead of a 404 for unpublished content?"

    Nope

    "Ideally it would also be good to have the ability to return the 404 page for those requests with a 410 response but unfortunately your solution won't work in our case where we have a multi-site install and each language has it's own 404."

    To be honest, it's not the UrlTracker's responsibility what is shown when a 404 or 410 occurs. I handle this with my own customErrors code, which show a 404 or 410 page from umbraco when one of these errors occurs and it works really well :-)

  • Lachlann 343 posts 625 karma points
    Oct 13, 2015 @ 08:23
    Lachlann
    0

    Hey @kipusoep Is there any chance you could detail what your customErrors code is to handle this? I have run into the same problem and I don't seem to be able to solve it. I basically want to be able to redirect users to my a custom error page on 410 in the same way as we do when there is a 404 in Umbraco.

    Cheers L

  • Lachlann 343 posts 625 karma points
    Apr 11, 2016 @ 12:51
    Lachlann
    0

    Forgot i asked this question but just came across it again. For anyone else the solution i put in place was as follows: Update your httpErrors tag in the web.config to something like:

    <httpErrors errorMode="Custom"  existingResponse="Replace">
      <remove statusCode="410" subStatusCode="-1" />
      <remove statusCode="404" subStatusCode="-1" />
      <error statusCode="410" subStatusCode="-1" path="/error/410" prefixLanguageFilePath="" responseMode="ExecuteURL" />
      <error statusCode="404" subStatusCode="-1" path="/error/404" prefixLanguageFilePath="" responseMode="ExecuteURL" />
    </httpErrors>
    

    Write map a new Umbraco route:

                RouteTable.Routes.MapUmbracoRoute(
                "ErrorPage",
                "error/{code}",
                new
                {
                    controller = "Error",
                    action = "GetErrorPage"
                },
               new UmbracoVirtualNodeByIdRouteHandler(Convert.ToInt32(ConfigurationManager.AppSettings["VirtualRouteErrorPageId"])));
    

    Write the corresponding controller to handle the route:

        public ActionResult GetErrorPage(RenderModel model, string code)
        {
            Response.StatusCode = int.Parse(code);
            return View("ErrorPage", new RenderModel(Umbraco.TypedContent(ERROR_PAGE_NODE_ID)));
        }
    

    This should give you the flexibility to customise what ever you need for different error codes etc...

    If this is a crazy thing to do let me know but it seems to work for me :)

    L

  • vcd 4 posts 75 karma points
    Dec 12, 2016 @ 14:39
    vcd
    0

    Hi, I've also searched this topic and so far this is the only working suggestion I've found :) would it be too much to ask you where you placed the map and controller? Thanks!

  • Lachlann 343 posts 625 karma points
    Dec 12, 2016 @ 16:04
    Lachlann
    0

    Hey, the Route map should inherit ApplicationEventHandler I think and your controller needs to be created in controllers and have the appropriate name that is used in your route so in my example above:

                controller = "Error",
                action = "GetErrorPage"
    

    I hope that helps. i noticed in the newer versions of Umbraco there is a native redirect handler so not sure if this package will become obsolete soon.

    Best L

  • vcd 4 posts 75 karma points
    Dec 13, 2016 @ 09:50
    vcd
    0

    thanks for the speedy reply! will check it out

  • Murray Roke 467 posts 875 karma points c-trib
    Sep 17, 2017 @ 23:05
    Murray Roke
    0

    Hi, I have the same setup as @Lachlann but my 410 responses are all empty, I tried using the same response as 404 (which works)

    when I visit http://example.com/NotFound or http://example.com/asdf I see the custom not found page. but when I visit http://example.com/unpublished-page/ I get a 410 with a blank response.

    Any ideas?

    Here's my web.config setup. (I tried with subStatusCode and prefixLanguageFilePath as per Lachlann's example but didn't make any difference)

    <httpErrors existingResponse="Replace" errorMode="Custom">
      <remove statusCode="400" />
      <remove statusCode="404" />
      <remove statusCode="410" />
      <remove statusCode="500" />
      <error statusCode="400" path="/ServerError.html" responseMode="ExecuteURL" />
      <error statusCode="404" path="/NotFound" responseMode="ExecuteURL" />
      <error statusCode="410" path="/NotFound" responseMode="ExecuteURL" />
      <error statusCode="500" path="/ServerError.aspx" responseMode="ExecuteURL" />
    </httpErrors>
    
  • Murray Roke 467 posts 875 karma points c-trib
    Sep 18, 2017 @ 03:39
    Murray Roke
    0

    Oh wierd, Once I built the controller for /Gone/ instead of using the 404 controller it worked (the only difference being the response code)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies