Web Application with custom error page

Niren Adhikary (NAD) 146 Reputation points
2022-07-14T16:23:48.737+00:00

Hello,

How can we display a custom error page in case 404, 500 error to user for our website hosted in Azure Web App ?

Thanks,

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,178 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Dillon Silzer 57,831 Reputation points Volunteer Moderator
    2022-07-14T16:41:32.753+00:00

    In another similar case:

    https://learn.microsoft.com/en-us/answers/questions/628589/web-appswindows%E3%81%A6%E3%81%AE404%E3%82%A8%E3%83%A9%E3%83%BC%E3%83%98%E3%83%BC%E3%82%B7%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%9E%E3%82%A4%E3%82%B9.html

    For customization, you may edit web.config file located in D:\home\site\wwwroot folder.

    You may try this code (copied below), answer from a similar SO discussion thread.
    For more details on customErrors flag.

     <?xml version="1.0" encoding="UTF-8"?>  
     <configuration>  
         <system.webServer>  
             <httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL">  
                 <remove statusCode="404" subStatusCode="-1" />  
                 <error statusCode="404" path="/404.asp" responseMode="ExecuteURL" />  
             </httpErrors>  
         </system.webServer>  
     </configuration>  
    

    If this helps please mark as correct answer or upvote.


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.