Secret ingredients to quality software

Do you present the user with a nice error screen?

Last updated by Brady Stroud [SSW] on 05 Oct 2021 11:11 pm (about 2 months ago) See History

Your users should never see the “yellow screen of death”. Errors should be caught, logged and a user-friendly screen displayed to the user.

error screen bad
Figure: Bad Example – ASP.NET Yellow Screen of Death

net core default
Figure: Bad Example - Default exception page

error screen good
Figure: Good Example - GitHub custom error page

However, as a developer you still want to be able to view the detail of the exception in your local development environment.

How-to set up development environment exception pages in ASP.NET Core

To set up exceptions in your local development environment you need to configure the Developer Exception Page middleware in the request processing pipeline. Unless you have modified the default template, it should work out of the box. Here are the important lines:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    if (env.IsDevelopment())

net core development
Figure: This is how you set it up in .NET 5

Find out more about exception handling in .NET Core 5 here.

Adam CoganAdam Cogan
Drew RobsonDrew Robson
Matt WicksMatt Wicks
Piers SinclairPiers Sinclair
Jake BaylissJake Bayliss

We open source. Powered by GitHub