We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

custom error pagesRSS

2 replies

Last post Jan 21, 2021 05:37 PM by Rovastar

  • custom error pages

    Jan 18, 2021 08:17 AM|EyalD|LINK

    Hi All

    we have a custom error pages in our sites.

    for some reason when opening dev tools (in browser) the error pages that configured as aspx returns 404 but the htm\html pages returns 200.

    why is that?

    thanks 

    E

  • Re: custom error pages

    Jan 19, 2021 02:25 AM|Brucz|LINK

    Hi EyalD,

    If you set the responseMode is ExecuteURL, it will return 200. Because it is also a request for error page.

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

    Set the responseMode to File will make status code to 404, not 200.

     <httpErrors errorMode="Custom">
                <remove statusCode="404" subStatusCode="-1" />
                <error statusCode="404" prefixLanguageFilePath="" path="404.html" responseMode="File" />
     </httpErrors>

    Best regards,

    Brucz

    .NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
  • Rovastar Rovastar

    5495 Posts

    MVP

    Moderator

    Re: custom error pages

    Jan 21, 2021 05:37 PM|Rovastar|LINK

    Because IIS errors (html pages, etc). and asp.net errors handling are very different beasts. You will need to configure both to have a complete site. 

    Troubleshoot IIS in style
    https://www.leansentry.com/