...

/

Controlling the Hosting Environment

Controlling the Hosting Environment

Learn about the automatic handling of exceptions in development mode and setting the hosting environment for local development.

In ASP.NET Core 5 and earlier, the project template set a rule to say that while in development mode, any unhandled exceptions will be shown in the browser window for the developer to see the details of the exception, as shown in the following code:

Press + to interact
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

With ASP.NET Core 6 and later, this code is executed automatically, so it is not included in the project template. How does ASP.NET Core know when we are running in development mode so that the IsDevelopment method returns true? ...