Custom 404 Error Page? - General Discussions - General Discussions - Progress Community
 General Discussions

Custom 404 Error Page?

  • Custom 404 Error Page?
  • 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?
  • 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
  • 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?
  • 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
  • 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!
  • 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
  • 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
  • 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>
  • 257211_404-Error.zip
    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
  • 257288_sitefinity-errors.PNG
    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
  • 257393_IIS-Custom-Error-redirection.zip
    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
  • 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
  • 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
  • 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: 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.