Resolve Issue : ASP.NET Core 2.1 runs fine locally but when publishing to Azure says “An error occurred while starting the application.”

After building my first production ready application with ASP.NET Core 2.1 and tested locally when i tried to deploy for the first time on Azure, I was stuck with the following page.

Since many different problems can cause this error page, I would strongly recommend the following in order to determine the root cause quickly and easily, without meddling with Azure.

You can enable extremely helpful developer friendly error messages at startup by setting the .UseSetting(“detailedErrors”, “true”) and .CaptureStartupErrors(true) actions in your Program.cs file.

public class Program
public static void Main(string[] args)
public static IWebHost BuildWebHost(string[] args) =>
.UseSetting("detailedErrors", "true")

With the above settings publish your application to azure. Once you identify the root cause and resolve your issue, These above settings should be removed as soon as your troubleshooting is complete so as not to expose your application to malicious attacks.

Hope this helps someone out there.













Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.