
By default, ASP.NET Core suppresses Exceptions on Startup on external environments.
So you only get Exceptions in Startup on localhost.
Sometimes, especially on remote hosts like Azure, AWS or hosted virtual machines you deploy your app and you only get:

This does not help, if you do not log this error to an external data blob like Application Insights.
Enable error details
Often this happens if you forget to copy a dependency or have a typo in your settings files. But this is hard to debug! Also, the entire application process cashes, which is the reason you cannot normally attach a debuger (it never worked for me!).
To get a better error detail you have to activate detailed errors.
Open your program.cs and add .UseSetting("detailedErrors", "true") and .CaptureStartupErrors(true).
It now should look like
1
2namespace BenjaminAbt.ErrorHandlingSample
3{
4 public class Program
5 {
6 public static void Main(string[] args)
7 {
8 var host = new WebHostBuilder()
9 .UseKestrel()
10 .UseContentRoot(Directory.GetCurrentDirectory())
11 .UseIISIntegration()
12 .UseApplicationInsights()
13 .UseStartup<Startup>()
14 .UseSetting("detailedErrors", "true")
15 .CaptureStartupErrors(true)
16 .Build();
17
18 host.Run();
19 }
20 }
21}
Now you get on remote a detailed error page, too.

Related articles

Jan 28, 2020 · 8 min read
Warum IP-Adressen kein eindeutiges Merkmal sind
Immer wieder sieht man in Code, der für den Login eines Benutzers verwendet wird, dass mit Hilfe der IP-Adresse oder zum Beispiel auch dem …

Oct 04, 2019 · 2 min read
Using ASP.NET Core 3 in .NET libraries
With the release of ASP.NET Core 3, Microsoft has also changed the way how to use and reference ASP.NET Core dependencies. In the past you …

Feb 20, 2026 · 9 min read
.NET 11 Preview 1 Is Here: What's New and What to Expect
The .NET team just released the first preview of .NET 11 and there is already a lot to talk about. While this is an early preview - not a …
Let's Work Together
Looking for an experienced Platform Architect or Engineer for your next project? Whether it's cloud migration, platform modernization or building new solutions from scratch - I'm here to help you succeed.

Comments