Custom Error Page not shown - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Custom Error Page not shown

  • Custom Error Page not shown
  • Hi,
    A website done in sitefinity 5 is showing customised error page in my local machine. 

    This is the web.confiog code: 

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

    But in the server, it is not showing the error page. Is it related to IIS?
    Instead of going to the custom 404.aspx page, it goes to the  IIS 404 page. 

    Thanks.
  • I have trouble getting this to work reliably.

    I am running standard extensionless URLs.

    If I request  www.mysite.com/missingpage.aspx  then my custom 404 page works fine.
    If I request  www.mysite.com/missingpage  then the default IIS 404 page is displayed.

    I haven't managed to get to the bottom of why it behaves this way.
  • From what I've experienced (IIS6), it seems like IIS is handling your second request before it even gets to Sitefinity because it thinks its a folder that doesn't exist.  I was able to circumvent this problem by writing a .ashx Handler and then pointing my IIS 404 error to my handler which would in turn get run by .NET/Sitefinity.
  • Not quite sure I follow that... if IIS rejects because it 'thinks' it's an invalid folder, then how could it pass ANY extensionless requests... everything would be invalid until Sitefinity handles it.
  • I am not sure of the exact cause, I just noticed the behavior.  I noticed that my custom error section in my web.config wasn't handling in that situation.  So I changed IIS's 404 page to a test page,  In the case of the invalid extentionless url, it navigated to my test page.  Once, I pointed IIS to my handler everything started working.
  • Hi guys,

    Basically the easiest way to get your custom errors working in Sitefinity you need to modify the webconfig and  configure IIS accordingly ( please check the attached screenshots ).

    Also the bellow code can be used to perform a 404 redirect to a custom error page created in Sitefinity:

    <customErrorsmode="On">
         <errorstatusCode="404"redirect="error-404"/>
       </customErrors>

    Kind regards,
    Victor Velev
    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
  • Same problem here!
    The only way it works is setting it as suggested by Victor via IIS (httperror level rather than customerror)...

    customErrors tag just seems to get ignored no matter what combination I try...

  • Here is how I approached this problem.

    I actually created straight HTML web pages for all of my custom error pages.  I also set the redirect mode to ResponseRewrite so that our users don't see the path to /error.  Below is an example of what I actually did here.

    <customErrors mode="On" redirectMode="ResponseRewrite">
      <error statusCode="500" redirect="~/error/error.html"/>
      <error statusCode="404" redirect="~/error/page-not-found.html"/>
    </customErrors>

    There are several reasons why I chose to use straight HTML pages, but the biggest was that if there were issues, for example with the database, how would the page get served up correctly.  I am basically going back to the lowest common denominator and this will ensure that if an error occurs that my custom errors will display.  Hopefully this was helpful.  

    Enjoy!
  • 404 CUSTOM PAGE - WORKS .ASPX & NON .ASPX URLS WORKS ON GODADDY SHARED WINDOWS HOSTING (IIS7 .net4)

    Create a 404.html or 404.aspx file on your local main folder in your shared godaddy hosting.

    -Web.Config File-

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
       
    <system.webServer>
             
    <rewrite>
               
    <rules>
                   
    <rule name="Main Rule" stopProcessing="true">
                       
    <match url=".*" />
                       
    <conditions logicalGrouping="MatchAll">
                           
    <add input="REQUEST_FILENAME" matchType="IsFile" negate="true" />
                           
    <add input="REQUEST_FILENAME" matchType="IsDirectory" negate="true" />
                       
    </conditions>
                       
    <action type="Rewrite" url="404.html or 404.aspx" />
                   
    </rule>
               
    </rules>
           
    </rewrite>
       
    </system.webServer>
    </configuration>
  • I had trouble with this too and found that you have to add elements both to system.web/customErrors AND system.webServer/httpErrors.  The first handles ASP.NET 404s (like a request to the non-existent /doesntexist.aspx page).  The second handles requests to missing folders or files (like /bogus or /bogus.htm).

    I wrote a blog post with a few more details: http://wp.me/p29W52-69