Displaying custom error page at startup

Viewed 1163

Is there a way to display a custom error page when an exception occurs during the startup phase of an ASP.NET Core application? For example, if an exception occurs (db is down etc.) in any of the methods of the Startup class i.e. Configure, ConfigureServices, Startup.Ctor etc.?
I think that using the following code isn't going to help me

if (env.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
    app.UseStatusCodePages();
    app.UseBrowserLink();
}
else
{
    app.UseExceptionHandler("/Home/Error");
}  

as the middleware pipline isn't constructed yet. So the line

app.UseExceptionHandler("/Home/Error");  

isn't executed as a consequence.
Is there a way to display a custom error page if an error occurs at this stage?

thanks
ashilon

2 Answers
Related