Setting errorPage in Umbraco

前端 未结 2 1693
孤街浪徒
孤街浪徒 2020-12-17 06:20

I am developing a web application using Umbraco. I create a content called PageNotFound and, in the errors section of umbracoSettings.config file, I put the node id of that

相关标签:
2条回答
  • 2020-12-17 06:57

    The 500 errors did not work until I added

    existingResponse="Replace"
    

    like that

    <httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404" subStatusCode="-1" />
      <remove statusCode="500" subStatusCode="-1" />
      <error statusCode="404" path="/non-existing-page.aspx" responseMode="ExecuteURL" />
      <error statusCode="500" path="error.html" responseMode="File" />
    </httpErrors>
    
    0 讨论(0)
  • 2020-12-17 07:07

    In your web.config (system.webServer section) you can tell the site to pass all of the error handling through to the application:

    <httpErrors existingResponse="PassThrough" />
    

    This has the disadvantage that Umbraco doesn't handle anything but .aspx pages that are not found.

    You could make it better by doing something like this instead:

    <httpErrors errorMode="Custom">
           <remove statusCode="404" subStatusCode="-1" />
           <error statusCode="404" prefixLanguageFilePath="" path="/non-existing-page.aspx" responseMode="ExecuteURL" />
    </httpErrors>
    

    The non-existing-page.aspx does not exist yet in Umbraco, so it triggers a 404 (because it has the aspx extension) and.. presto: Umbraco handles the 404 perfectly!

    0 讨论(0)
提交回复
热议问题