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

Forums / Developing with Sitefinity / Custom Error Page not shown

Custom Error Page not shown

10 posts, 0 answered
  1. Surya CD
    Surya CD avatar
    57 posts
    Registered:
    06 Apr 2010
    10 Jul 2012
    Link to this post
    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.
  2. MB
    MB avatar
    302 posts
    Registered:
    09 Jan 2005
    11 Jul 2012
    Link to this post
    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.
  3. Brett Whittington
    Brett Whittington avatar
    89 posts
    Registered:
    10 Aug 2012
    11 Jul 2012
    Link to this post
    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.
  4. MB
    MB avatar
    302 posts
    Registered:
    09 Jan 2005
    11 Jul 2012
    Link to this post
    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.
  5. Brett Whittington
    Brett Whittington avatar
    89 posts
    Registered:
    10 Aug 2012
    11 Jul 2012
    Link to this post
    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.
  6. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    12 Jul 2012
    Link to this post
    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
  7. Richard
    Richard avatar
    77 posts
    Registered:
    24 Oct 2007
    17 Sep 2012
    Link to this post
    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...

  8. Craig
    Craig avatar
    45 posts
    Registered:
    28 Sep 2008
    17 Sep 2012
    Link to this post
    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!
  9. Yusf
    Yusf avatar
    1 posts
    Registered:
    06 Oct 2012
    06 Oct 2012
    Link to this post

    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>
  10. Ben
    Ben avatar
    3 posts
    Registered:
    01 Oct 2012
    12 Oct 2012
    Link to this post
    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
10 posts, 0 answered