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

Forums / General Discussions / Custom HTML error pages

Custom HTML error pages

10 posts, 0 answered
  1. Leonidius
    Leonidius avatar
    10 posts
    Registered:
    02 Jul 2014
    24 Jun 2015
    Link to this post

    Is there any objection to use IIS/ASP.NET approach to build custom error pages in pure HTML instead of the content pages hosted by Sitefinity itself ? This way we can get correct HTTP error codes returned without additional coding and make error pages available even if Sitefinity is not working. 

    My configuration (for a 404 error page) looks like this and works correctly. Just wondering if there any side effect not using Sitefinity-hosted  pages ?

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

        <httpErrors errorMode="Custom">
          <remove statusCode="404" subStatusCode="-1" />
          <error statusCode="404" path="Errors\404.html" responseMode="File" />
        </httpErrors>

  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    30 Nov 2016
    29 Jun 2015
    Link to this post
    Hello,

    There is no impact if not using Sitefinity pages, Sitefinity is asp.net application and you are using the Asp.net built in functionality while Sitefinity is not active which is perfectly fine.

    I usually do custom errors like below, however use any method that you find more suitable.
    <httpErrors errorMode="Custom">
          <remove statusCode="404"/>
          <error statusCode="404" prefixLanguageFilePath=""  path="HtmlPage.html" responseMode="Redirect"/>
        </httpErrors>
     
      </system.webServer>

    Regards,
    Stanislav Velikov
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. Leonidius
    Leonidius avatar
    10 posts
    Registered:
    02 Jul 2014
    29 Jun 2015 in reply to Stanislav Velikov
    Link to this post
    With the Redirect I will get 302 error code, not 404, right ?
  4. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    30 Nov 2016
    02 Jul 2015
    Link to this post
    Hi,

    301 is a redirect, 302 is another type of redirect, handle all types of redirect if needed, however for 301 make sure to have an entry.

    Regards,
    Stanislav Velikov
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  5. Leonidius
    Leonidius avatar
    10 posts
    Registered:
    02 Jul 2014
    02 Jul 2015 in reply to Stanislav Velikov
    Link to this post
    OK, I meant 301. In other words if I use responseMode="Redirect"  the return code will be 301, not 404. In my opinion a site  should always return 404 code when requested resource is not found. With responseMode="File" I can achieve it via server-side redirect, right ?
  6. MB
    MB avatar
    302 posts
    Registered:
    09 Jan 2005
    06 Jul 2015 in reply to Leonidius
    Link to this post
    Personally, I prefer to use the IIS rewrite module for handling 301 and 302 redirects, as I find it more flexible and powerful.
  7. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    30 Nov 2016
    07 Jul 2015
    Link to this post
    Hi,

    @ Leonidius Here I am not sure I understand "With responseMode="File" I can achieve it via server-side redirect, right ?" Please elaborate on this.

    When the responceMode is set to file the server returns an html file for error page, more info on all responceModes here.

    When configuring httpErrors to handle 404 status codes every time a request to Url return 404 the httpErrors config will get you to redirect from the 404 error page to the predefined error page that the user should get.
    <httpErrors errorMode="Custom">
          <remove statusCode="404"/>
          <error statusCode="404" prefixLanguageFilePath=""  path="HtmlPage.html" responseMode="Redirect"/>
        </httpErrors>
      
      </system.webServer>

    Regards,
    Stanislav Velikov
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  8. Leonidius
    Leonidius avatar
    10 posts
    Registered:
    02 Jul 2014
    07 Jul 2015 in reply to Stanislav Velikov
    Link to this post

     Stanislav, 

    My goal is to return 404 HTTP error code when page is not found. With responseMode="Redirect" I'll get 301, not 404.  Only with  responseMode="File" I can get the 404 code, right ?

  9. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    30 Nov 2016
    10 Jul 2015
    Link to this post
    Hello,

    Yes with responseMode="File" upon encountering an error the opened page for error will be returned with status 404. Note the file needs to be .html file to get rendered.
    <httpErrors errorMode="Custom">
          <remove statusCode="404"/>
          <error statusCode="404" prefixLanguageFilePath=""  path="HtmlPage1.html" responseMode="File"/>
        </httpErrors>

    Regards,
    Stanislav Velikov
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  10. Tim
    Tim avatar
    258 posts
    Registered:
    22 Jun 2011
    18 Jul 2015
    Link to this post

    If anyone else is looking for a solution to this, check out the custom error page module I put on GitHub.

     I uploaded a short demo video to YouTube so you can see how it works.

10 posts, 0 answered