How to configure a custom error 404 page in azure app service

Neerav Agrawal 50 Reputation points
2023-07-20T15:28:27.34+00:00

How to configure a custom error 404 page in azure app service

In configurations -> error pages - I do see the options for 403, 502, 503 error pages only. But not sure how to configure 404 page?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,685 questions
{count} votes

2 answers

Sort by: Most helpful
  1. VenkateshDodda-MSFT 24,671 Reputation points Microsoft Employee
    2023-07-28T10:25:30.4666667+00:00

    @Neerav Agrawal apologize for the delay in my response. You might have missed to attach the output what you are getting.
    Custom error pages are for errors that terminate on the FrontEnd (ie, request that doesn't make to your app). In this sense a 404-error page is not meaningful, since when a 404 comes from the FrontEnd it means we were unable to find a site for a hostname in the first place! 

    Once the request gets to the app it is assumed the customer can use whatever error page they want.

    I have written the below custom error config in my web.config file and test it as well. All the requests coming to the root url of the webapp it is showing the default page if we request to the path which doesnt exists in my application. it is redirecting the content in 404.html file. As shown below.

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

    User's image

    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.