Search code examples
c#asp.net-coreexception.net-5custom-error-pages

Override the default error page 500.30 - ASP.NET Core app failed to start


I am attempting to create a custom error page display to run in my app when there is an issue with the database connection string. When I alter the string to something invalid, I receive the error mentioned in the title above.

Is there any way to override this page and show a more informative one that would tell me that my DB connection string is wrong? There is a InvalidOperationException that is thrown in the Startup.cs file, but I'm unsure on how to extract this from the startup file and use it, when my app fails to start in the first place.

Is this possible to do?


Solution

  • You can disable the default error page by using the disableStartUpErrorPage="true" setting in web.config for the IIS hosting module. This will just fallback to another custom error page of your choosing served by IIS, rather than allowing you to show a dynamic custom page.

    Documentation