Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt Whetton 19 posts 61 karma points
    Feb 19, 2014 @ 12:10
    Matt Whetton
    1

    Custom 500 Error Page

    I'm trying to configure a static html page as a custom 500 error page in our umbraco solution. To test I took my umbraco database offline (simulating a connection issue or something like that).

    Using the custom errors section did not work, as it seems that umbraco is trying to do some sort of authroization checking on static html files...at which point it fails as the database is not available. I managed to serve the static html page by adding the following for the httpErrors section in our web.config:

        <httpErrors errorMode="Custom" existingResponse="Replace">

          <remove statusCode="500" subStatusCode="-1"/>

          <error statusCode="500" path="error-500.html" responseMode="File" />

        </httpErrors>

    This allows the static error-500.html file to be rendered, but I'm still unable to reference any other files in my installation (such as images and css) as they all throw 500 errors themselves (presumably due to this authorization).

    Can I make umbraco serve specified paths without trying to do any authorization? So just serve them as simple static files.

     

     

  • Kasper Holm 47 posts 180 karma points
    Feb 19, 2014 @ 13:41
    Kasper Holm
    0

    Hello Matt

    what i think you need to do is add you html file path to your web.config in the key "umbracoReservedUrls", this tells umbraco that it should not take over that url :)

  • Matt Whetton 19 posts 61 karma points
    Feb 19, 2014 @ 13:52
    Matt Whetton
    0

    Thanks for replying so fast.

    Unfortunately I just tried it and it hasn't worked - I get the same issue with the static html page request throwing an exception. Looks like the same exception too:

    [SqlException (0x80131904): Cannot open database "DatabaseName" requested by the login. The login failed.
    Login failed for user 'Username'.]
       System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +642
       System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +116
       System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +1089
       System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +6785863
       System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +233
       System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +278
       System.Data.SqlClient.SqlConnection.Open() +239
       Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters) +94
       umbraco.DataLayer.SqlHelpers.SqlServer.SqlServerHelper.ExecuteReader(String commandText, SqlParameter[] parameters) +26
       umbraco.DataLayer.SqlHelper`1.ExecuteReader(String commandText, IParameter[] parameters) +161
    
    [SqlHelperException: Umbraco Exception (DataLayer): SQL helper exception in ExecuteReader]
       umbraco.DataLayer.SqlHelper`1.ExecuteReader(String commandText, IParameter[] parameters) +361
       umbraco.BusinessLogic.User.setupUser(Int32 ID) +190
       jumps.umbraco.usync.SyncTemplate.ReadFromDisk(String path) +65
       jumps.umbraco.usync.uSync.ReadAllFromDisk() +167
       jumps.umbraco.usync.uSync.RunSync() +475
       jumps.umbraco.usync.uSync.DoOnStart() +138
       Umbraco.Core.EnumerableExtensions.ForEach(IEnumerable`1 items, Action`1 action) +148
       Umbraco.Core.CoreBootManager.Complete(Action`1 afterComplete) +116
       Umbraco.Web.WebBootManager.Complete(Action`1 afterComplete) +359
    
    [HttpException (0x80004005): Umbraco Exception (DataLayer): SQL helper exception in ExecuteReader]
       System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12949749
       System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175
       System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
       System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
       System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
    
    [HttpException (0x80004005): Umbraco Exception (DataLayer): SQL helper exception in ExecuteReader]
       System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12966756
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12806561
    
  • Kasper Holm 47 posts 180 karma points
    Feb 19, 2014 @ 14:44
    Kasper Holm
    0

    hmm, that sounds like it's not ignoring the URL you can try and add the path to "umbracoReservedPaths"

    also you could try and set the exit response on errors to PassThrough.

    <system.webServer>
      <httpErrors existingResponse="PassThrough" />
    </system.webServer>
    
  • Matt Whetton 19 posts 61 karma points
    Feb 19, 2014 @ 14:50
    Matt Whetton
    0

    Yes, that is my exact configuration right now, looks like this:

    httpErrors Section:

    <httpErrors existingResponse="PassThrough" />
    

    customErrors section

    <customErrors defaultRedirect="error-500.html" mode="RemoteOnly">
    </customErrors>
    

    And appSettings umbracoReservedPaths part:

    <add key="umbracoReservedUrls" value="~/error-500.html,~/config/splashes/booting.aspx,~/install/default.aspx,~/config/splashes/noNodes.aspx,~/VSEnterpriseHelper.axd" />
    

    This is giving me the error stated above

    Thank you so much for your help.

  • Kasper Holm 47 posts 180 karma points
    Feb 19, 2014 @ 15:08
    Kasper Holm
    0

    Okay, that is wierd..

    you may have to add

     <system.webServer>
          <httpErrors errorMode="DetailedLocalOnly" defaultResponseMode="File">
                <error statusCode="500" path="/notfound.html" responseMode="ExecuteURL" />
           </httpErrors>
      </system.webServer>
    

    (found it here http://kitsula.com/Article/MVC-Custom-Error-Pages it seems to be the MVC part thats making changes to id)

    let me know if it helps :)

  • Matt Whetton 19 posts 61 karma points
    Feb 19, 2014 @ 15:17
    Matt Whetton
    0

    Afraid not, still getting the same error.

    If I change it to:

    <httpErrors errorMode="Custom" existingResponse="Replace">
        <remove statusCode="500" subStatusCode="-1"/>
        <error statusCode="500" path="error-500.html" responseMode="File" />
    </httpErrors>
    

    It will return the error-500.html page, but it still throws the same exception for all other files (like css and images)

  • Kasper Holm 47 posts 180 karma points
    Feb 19, 2014 @ 15:23
    Kasper Holm
    0

    so now youre getting the page, but all other reqeust like css files is throwing the exeption ? maybe this is caused by umbracos standard 404 handler ? :)

  • Matt Whetton 19 posts 61 karma points
    Feb 19, 2014 @ 15:43
    Matt Whetton
    0

    Ok, I think I've found the problem! I've been using uSync and if I turn it off it seems to resolve the issue.

    Obviously uSync tries to sync everything to the database as it loads up, which it cant so it errors.

    Thanks for all your help

  • Pavel Gurecki 55 posts 158 karma points
    Jun 05, 2014 @ 11:02
    Pavel Gurecki
    0

    Hi guys,

    great thread, managed to show static html based on your posts.

    But now I have same problem as Matt's - exception is thrown for all resources (css, images, etc) included in static error page.

    In my case it is uSitebuilder which also has autosync causing this. Some workaround as inlining css and similar can be implemented.

    But there is another, more serious issue with error page:

     <httpErrors errorMode="DetailedLocalOnly"  existingResponse="Replace" >

    With this code custom error will be shown for remote connected users and detailed error for connecting locally. Custom error static html is shown fine, but when connecting locally I see IIS error (HTTP Error 500.0 - Internal Server Error), not the ASP.NET one with exception details. The problem is that there is no usefull info like stack trace, etc. in IIS error which makes debuging practically impossible. 

    If you set existingResponse="PassThrough"   even with errorMode="Custom" detailed error is shown and custom error page not.

    Any ideas how to make custom error page working along with asp.net detailed error page for local connections? 

    I am thinkng of using errorMode="Auto" and setting Response.TrySkipIisCustomErrors=true; but don't know where to do that.

  • Janne Mårtensgård 11 posts 232 karma points
    Jan 26, 2016 @ 09:12
    Janne Mårtensgård
    0

    Hi,

    We're also having troubles with this. Can replicate it on a fresh install of 7.3.5 (add an error.htm page, config as above, change connection string to db).

    Is there any way to hook into the startup process? I e check if the database is available and redirect to a custom page before Umbraco tries to connect to it.

  • Manish 373 posts 932 karma points
    Apr 28, 2016 @ 11:59
    Manish
    0

    When you enable 500 custom error page it catches ALL ERRORS, including exceptions on web api.

    To enable 500 error page and still have exception on webapi you must edit your web.config file like this

    1. edit httpErrors for 500 and 404 pages

    <httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404"/>
      <error statusCode="404" prefixLanguageFilePath="" path="/not-foun" responseMode="ExecuteURL" />
    
      <remove statusCode="500"/>
      <error statusCode="500" path="Error500.html" responseMode="File"/>
    </httpErrors>
    
    ....
    

  • Manish 373 posts 932 karma points
    Apr 28, 2016 @ 11:59
    Manish
    0

    When you enable 500 custom error page it catches ALL ERRORS, including exceptions on web api.

    To enable 500 error page and still have exception on webapi you must edit your web.config file like this

    1. edit httpErrors for 500 and 404 pages

    <httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404"/>
      <error statusCode="404" prefixLanguageFilePath="" path="/not-foun" responseMode="ExecuteURL" />
    
      <remove statusCode="500"/>
      <error statusCode="500" path="Error500.html" responseMode="File"/>
    </httpErrors>
    
    ....
    

  • Manish 373 posts 932 karma points
    Apr 28, 2016 @ 11:59
Please Sign in or register to post replies

Write your reply to:

Draft