I created custom 500 error page in ASP.NET Core 3.0 Razor Pages application for environments different than development. The custom 500 page is using the same layout as the other pages and if some of the components which is added directly in the layout (like header/footer) errors then I can see server 500 error page, not my custom error page.
Would it be possible somehow to fallback to a completely static html page in this case? If so, how to do it?
Below are the middleware I am using at the moment.
Startup.cs:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Errors/Error500");
app.UseStatusCodePagesWithReExecute("/Errors/Error{0}");
}
}