locked
mistakes in custom errors for web.config RRS feed

  • Question

  • User2110873642 posted

    i have gotten an error page that an error occured, and aditionally another error occured while displaying the custom error page.

    do i have any mistakes in this web.config data:

    <configuration>
      <system.web>
        <customErrors mode="On" redirectMode="ResponseRewrite">
          <error statusCode="404" redirect="/http404.aspx" />
        </customErrors>
      </system.web>
      <system.webServer>
        <httpErrors errorMode="Custom">
          <remove statusCode="404"/>
          <error statusCode="404" path="/http404.aspx" responseMode="Redirect"/>
        </httpErrors>
      </system.webServer>
    </configuration>

    additionally, is this confusing to google?

          <remove statusCode="404"/>

    or is any of the other stuff confusing to google?

    Friday, February 15, 2019 11:36 AM

All replies

  • User839733648 posted

    Hi fazioliamboina,

    According to your description, I'm sorry that I could not reproduce your issue successfully.

    I have some confusion.

    i have gotten an error page that an error occured, and aditionally another error occured while displaying the custom error page.

    What is the another error? Could you please show the error?

    additionally, is this confusing to google? or is any of the other stuff confusing to google?

    Do you mean that you think google could not identify the code?

    I'm really confused about what your actual error has met.

    I've also tested your code on my side. I've created a defalut 404 page and the code works well.

    Here is my testing code and how it works.

    http404.aspx

    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                This is default 404 error page.
            </div>
        </form>
    </body>
    </html>

    Test.aspx

    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
    <%-- set the href wrongly to make the 404 error --%> <a href="/w">Site Map</a> </form> </body> </html>

    Web.config

      <system.web>
        <compilation debug="true" targetFramework="4.6.1"/>
        <httpRuntime targetFramework="4.6.1"/>
        <customErrors mode="On" redirectMode="ResponseRewrite">
          <error statusCode="404" redirect="/http404.aspx" />
        </customErrors>
      </system.web>
      <system.webServer>
        <httpErrors errorMode="Custom">
          <remove statusCode="404"/>
          <error statusCode="404" path="/http404.aspx" responseMode="Redirect"/>
        </httpErrors>
      </system.webServer>

    running result.

    Best Regards,

    Jenifer

    Monday, February 18, 2019 6:29 AM
  • User2110873642 posted

    hello,

    thanks for helping me out.

    well as you can notice, there are 2 segments in the config file that references to redirecting to the errorpage. maybe one and the other fire under different circumstances?

    unfortunately i cannot find out anymore what that error message was. at the time tho, all it showed on the webpage was nearly similar as this: "an error occured, and aditionally another error occured while displaying the custom error page." just one sentence. no details. i didnt had an implementation at the time that would notify me with error details for customers.

    all i know, is that for some people the custom error pages arent working. but the errors i tried to simulate all succcessfully show my error page.

    ---

    additional information: im using web forms, but i have set some routs in the global asax. all root path requests route to a subfolder like : '/subsites/home/'

    the error page refers to 'http404.aspx' (as you can see in the config) which would then route '/subsites/home/http404.aspx'

    there are two segments in the config file that redirects to the error page, my guess was, that maybe one or the other doesnt support the routing? as it maybe checks for the file to exist in the root folder?

    Monday, February 18, 2019 7:32 AM
  • User2110873642 posted

    oh and about google, i meant, can google know that the page doesnt exist?

    i dont want google to never remove outdated content, because it might be thinking all possible urls do exist on my server.

    Monday, February 18, 2019 7:35 AM
  • User839733648 posted

    Hi fazioliamboina,

    The error message in <system.web> and <system.webServer> appears in different condition.

    When you enter a page which its suffix is aspx, the page will go to the customErrors.

    And when you enter a page which its suffix is other like html, the page will go to the httpErrors.

    You could see my example.

      <system.web>
        <compilation debug="true" targetFramework="4.6.1"/>
        <httpRuntime targetFramework="4.6.1"/>
        <customErrors mode="On" redirectMode="ResponseRewrite">
          <error statusCode="404" redirect="/http404.aspx" />
        </customErrors>
      </system.web>
      <system.webServer>
        <httpErrors errorMode="Custom">
          <remove statusCode="404"/>
          <error statusCode="404" path="/http4044.aspx" responseMode="Redirect"/>
        </httpErrors>
      </system.webServer>

    how it works

    The path is the relative path of the error page in your project.

    Besides, Google has its own set of things to crawl all the content on the page.

    Google doesn't index URLs with a 404 status, so your error page doesn't pass link juice.

    Best Regards,

    Jenifer

    Tuesday, February 19, 2019 9:53 AM
  • User2110873642 posted

    absolutely cool beans. thanks so much! this makes so much sense to me now.

    however, do you have any tips i should add or change to my config, to be sure that all exceptions refer to the http404.aspx page.

    Tuesday, February 19, 2019 11:17 AM
  • User2110873642 posted

    if i go to my website/t.aspx, i get this page:

    Server Error in '/' Application.


    Runtime Error

    Description: An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page for the first exception. The request has been terminated.

    Tuesday, February 19, 2019 11:27 AM
  • User753101303 posted

    Hi,

    It means that you have a server side exception (which is not a 404 error, 404 is when you try to reach a page that doesn't exists). By default details are written to the Windows event log. See there to get more details about what happens).

    Once fixed, it seems you may want to add as well a 500 page (or you can define a default error page and then possibly set a page for the error code(s) for which you want some particular page).

    Tuesday, February 19, 2019 12:03 PM
  • User2110873642 posted

    but the page doesnt exist. i dont have a /t.aspx page

    Tuesday, February 19, 2019 12:04 PM
  • User753101303 posted

    Yes and so it runs your http404.aspx page which could then fail with some error.

    Anyway there is no point in discussing what could or couldn't happen when you should be able to just have to look at the Windows event log to see which error actually happens. And so once the problem is known it will be much easier to fix..

    Tuesday, February 19, 2019 12:33 PM
  • User2110873642 posted

    there is no log of it in the windows log events viewer.

    so what could it be?

    Wednesday, February 20, 2019 12:14 PM
  • User753101303 posted

    You already have exception handling code in your app maybe using Application_Error in global.asax then ?

    As pointed by the error message it seems you have a first exception (maybe in your 404 page ?) and then another exception happens in the code that is handling this first exception.

    Also from "to be sure that all exceptions refer to the http404.aspx page" it seems there is some confusion :
    - an exception is a runtime error in server side code
    - a "404 not found" error happens when the browser sends a request to the server and that the server doesn't find anything that matches (ie you try to reach a location that doesn't exists)

    Wednesday, February 20, 2019 5:39 PM
  • User2110873642 posted

    ok to clarify:

    • currently no error is caused in my code. it must have something to do with my web config file or the path to my page. also the windows event log viewer doesnt show the error, and also application_error does also not catch one, and neither does server.getlasterror get it. it simply isnt in my code. it is by the iis application that causes it, and i think it is in my web config file. the problem is neither in the http404.aspx page. the page has no code at all to run, its an empty page, just to test, with written 'hello world' inside the html. i really think it has something to do with routing in my web config file.
    • yes i need to know how to catch all error and exception types to show a proper friendly page for all kinds of exceptions. currently i only know how to catch the 404's for non aspx pages. the aspx 404 cause an error.
    Wednesday, February 20, 2019 7:35 PM
  • User753101303 posted

    Then you are not allowed to alter httpErrors for now ? See https://docs.microsoft.com/en-us/iis/manage/remote-administration/configuring-remote-administration-and-feature-delegation-in-iis-7#configure-default-delegation-states-for-features-in-iis-manager

    If "Error Pages" is on "Read Only" try to change this to "Read Write" and see if it solves the issue. In addition to the "Application" log you should also have a particular log for IIS administrative issues.

    Wednesday, February 20, 2019 8:16 PM
  • User2110873642 posted

    thank you, but unfortunately that wasnt it. its all set to allow read and write.

    Wednesday, February 20, 2019 8:19 PM
  • User753101303 posted

    I tried my next guess and see this error message if the error page doesn't exists. Only root requests are rerouted ? What if you try the actual page path ie something such as /subsites/home/http404.aspx (or /home/.http404.aspx ?).

    Wednesday, February 20, 2019 10:00 PM