Do you present the user with a nice error screen?
Updated by Brady Stroud [SSW] 1 year ago. See history

❌ Figure: Bad Example – ASP.NET Yellow Screen of Death

❌ Figure: Bad Example - Default exception page

✅ 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()){app.UseDeveloperExceptionPage();}else{app.UseExceptionHandler("/Error");app.UseHsts();}...}

✅ Figure: This is how you set it up in .NET 5
Find out more about exception handling in .NET Core 5 here.
Categories
Need help?
SSW Consulting has over 30 years of experience developing awesome software solutions.