Copied to clipboard

Flag this post as spam?

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


  • Zakhar 171 posts 397 karma points
    Feb 04, 2013 @ 12:40
    Zakhar
    0

    Dot in url breaks 404 handler

    Hi guys,

    I implemented my 404 handler as described here:

    http://our.umbraco.org/wiki/reference/files-and-folders/files-in-the-config-folder/404handlersconfig

    and here:

    http://our.umbraco.org/wiki/how-tos/how-to-implement-your-own-404-handler

    It works fine if I try to open a non existing page with url like /notexists or /not/exists (my custom not found page is displayed).

    Howewer if I try to go to a url containing a dot (e.g. /not.exists) it doesn't work and web server standard 404 error is displayed:

    404 - File or directory not found.
    The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

    Another issue is that when it works (with url /notexists and my custom page) it returns status code 200.

    So I have 2 questions:

    How to return 404 status code when a page is not found?

    How to make it work when a url contains a dot?

     

    P.S. I'm running Umbraco 4.7.2 and judging by this forum changes were made to 404 handling and new bugs introduced since 4.7.2. I still hope someone will share their succesfully working setup.

    Thank you.

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Feb 04, 2013 @ 12:45
    Stefan Kip
    100

    Using a dot in the URL automatically inclines the part after the dot is the extension, e.g. foo.aspx
    Umbraco will not handle any page with a different extension than .aspx, as mentioned in this invalid issue: http://issues.umbraco.org/issue/U4-1282 

    You can return a 404 status yourself in the 404handler:

    HttpContext.Current.Response.StatusCode = 404;
    HttpContext.Current.Response.Status = "404 Not Found";
    HttpContext.Current.Response.TrySkipIisCustomErrors = true;

     

     

     

     

     

Please Sign in or register to post replies

Write your reply to:

Draft