+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Custom 404 Error Page?

Custom 404 Error Page?

15 posts, 1 answered
  1. Chris
    Chris avatar
    63 posts
    Registered:
    05 Jan 2011
    02 Feb 2011
    Link to this post
    I apologize if this was already posted but I searched the forums and didn't find anything.  Lots of great notes on Sitefinity 3.X custom errors, but nothing on 4.0 from what I could find.

    How would I go about implementing a custom 404 error page in Sitefinity 4.0?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    30 Sep 2016
    03 Feb 2011
    Link to this post
    Hi Chris,

    Try using the ASP.NET custom errors element.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  3. Chris
    Chris avatar
    63 posts
    Registered:
    05 Jan 2011
    10 Feb 2011
    Link to this post
    Hi Ivan,

    So I included the following in web.config:

    <customErrors mode="On">
                <error statusCode="404" redirect="Errors/404.aspx" />
            </customErrors>

    It doesn't appear to be working.  It either errors out or Sitefinity intercepts.  For example, I have a URL that looks like this: http://localhost:60876/content-views/knowledgebase-entry/2011/02/04/how-do-i-call-the-licensing-key-in-my-application but when I enter the mistyped URL http://localhost:60876/content-views/knowledgebase-entry/2011/02/04/how-do-i-call-the-licenszing-keys-in-my-appplication Sitefinity displays a list of items in the content type.  This is not good, how do I dump it to a 404?

    Second, if I go to a page that literally doesn't exists like http://localhost:60876/not here  I get: 

    Server Error in '/' Application.

    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

    Requested URL: /nothere


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

    So, what am I doing wrong?
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    20 Sep 2016
    17 Feb 2011
    Link to this post
    Hello Chris,

    Could you please inspect the responses codes with Firebug or Fiddler2? If the URL is misspelled, you should get 404 code regardless of the page contents displayed?

    Regards,
    Georgi
    the Telerik team
  5. Chris
    Chris avatar
    63 posts
    Registered:
    05 Jan 2011
    17 Feb 2011
    Link to this post
    Hi Georgi,

    I figured out the problem with physical pages that do not exist, thank you.  How do I handle the case where Sitefinity grabs a URL that doesn't match up properly, such as the example in my first post.

    Thank you!
  6. Josh Anderson
    Josh Anderson avatar
    48 posts
    Registered:
    15 Dec 2005
    16 Mar 2011
    Link to this post
    Was there any resolution to this? I'm having the same problem -- I have custom errors enabled with a page specified for 404 errors, but I keep getting the default file-not-found error from IIS.

    UPDATE:
    I've determined that this only happens when requesting URLs that don't include extensions processed by ASP.NET. So with the customErrors section defined, I will get my custom 404 page when I request http://www.telephonypartners.com/foo.aspx, but not when I request http://www.telephonypartners.com/foo.

    I don't know if Sitefinity's url rewriting module processes these requests, but I suspect that it might. Any ideas how to get this to work?

    Josh
  7. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    19 Sep 2016
    18 Mar 2011
    Link to this post
    Hello Josh Anderson,

    Provided you have your custom e404 error page in Sitefinity, can you please try using the sample code below and tell me if it works for you. I have tested it and it works fine with Sitefinity's extensionless URLs.

    <customErrors mode="On">
          <error statusCode="404" redirect="~/404"/>
         </customErrors>


    Regards,
    Boyan Barnev
    the Telerik team
  8. Josh Anderson
    Josh Anderson avatar
    48 posts
    Registered:
    15 Dec 2005
    18 Mar 2011
    Link to this post
    The problem isn't the customErrors section in the web config. If you check out the links in my last post, you'll see that you do get the custom page supplied in that section (which does use a Sitefinity extensionless page in fact), but only when you use a url that has an extension.

    I can only assume that this is because the web.config settings apply only to requests that go through the ASP.NET ISAPI filter. If IIS sees a request without an extension, the only way it can know what to do with it is if there's a Sitefinity component in there processing the requests. This Sitefinity component appears not to be aware of the custom error configuration.

    For reference, here's my customErrors section in web.config:

    <customErrors mode="RemoteOnly" defaultRedirect="~/error">
      <error statusCode="404" redirect="~/not-found" />
    </customErrors>
  9. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    19 Sep 2016
    18 Mar 2011
    Link to this post
    Hi Josh Anderson,

    Thank you for getting back to me. Have you done some special settings in IIS concerning error redirection? Please see the attached video where I've tested 404 error redirection with my below pasted code and it works properly with both Sitefinity extensionless pages and custom physical (*.aspx) pages.

    Regards,
    Boyan Barnev
    the Telerik team
  10. Josh Anderson
    Josh Anderson avatar
    48 posts
    Registered:
    15 Dec 2005
    18 Mar 2011
    Link to this post
    I'm running a plain IIS7 site. It's set with default options for custom errors (see screen shot). Are you testing using IIS7 or IIS6?

    Josh
  11. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    19 Sep 2016
    19 Mar 2011
    Link to this post
    Hi Josh,

    Sorry for misleading you, I have tested this further and it seems that in case of extensionless page leading to 404 IIS is catching the error and it does not reach to Sitefinity at all. Please see the attached video showing how to set the custom error redirection properly from IIS.

    Best wishes,
    Boyan Barnev
    the Telerik team
  12. Chris
    Chris avatar
    63 posts
    Registered:
    05 Jan 2011
    21 Mar 2011
    Link to this post
    Hi Boyan,

    How do we handle the case where Sitefinity IS grabbing the URL and redirecting to a page it should not?  For example, http://localhost:60876/content-views/knowledgebase-entry/2011/02/04/how-do-i-call-the-licenszing-keys-in-my-appplication is the mis-typed URL (the correct URL is: http://localhost:60876/content-views/knowledgebase-entry/2011/02/04/how-do-i-call-the-licensing-key-in-my-applicationand yet it still goes to the list page.  This URL needs to throw a 404 and hit my custom error page.

    Chris
  13. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    19 Sep 2016
    21 Mar 2011
    Link to this post
    Hi Chris,

    Can you please review this PITS issue because it seems to me that your problem is the same - the page cannot be resolved, so you are returned to the list. We are working on fixing this bug, and you can track its progress on the link I provided.

    All the best,
    Boyan Barnev
    the Telerik team
  14. John
    John avatar
    22 posts
    Registered:
    14 Jan 2011
    19 Sep 2011
    Link to this post
    Hi,

    Besides «the page cannot be resolved» bug in PITS, there is another issue concerning this subject:

    I followed the last video posted by Boyan to set the custom error redirection properly from IIS. I did it in IIS 6.0 (not the same as in the video but I expected to work). It doesn't work...

    In my local project I get the right redirection to the custom error page when I browse a wrong page (i.e: http://localhost:60877/sitefi).
    But in my server site I get the default 404 IIS error page. I customized the 404 error page in the IIS 6.0 and it gives me this simple message « The file is not found » instead of my custom extension-less error page from Sitefinity.

    How can I implement this ?

    Thanks,

    John.

  15. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    19 Sep 2016
    20 Sep 2011
    Link to this post
    Hi John,

    This behavior is IIS specific, can you please make sure you are configuring everything as per this article from MSDN? If you want to use the <customErrors> element in your web.config, however, you'll need to configure wildcard mappings for IIS6, as they don't come built-in out of the box unlike IIS 7 and later versions.

    Greetings,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
15 posts, 1 answered