How do the different environments affect our web application's behavior?
Right after our web application starts, ASP.NET Core reads the ASPNETCORE_ENVIRONMENT environment variable and stores its value in the EnvironmentName property of our app's IWebHostEnvironment instance, which, as its name suggests, provides information about the web hosting environment our application is running in. Once set, this variable can be used programmatically – either directly or with some helper methods – to determine our app's behavior at any moment of our back-end life cycle.
We've already seen these methods in action in the Startup class of our .NET Core applications—for example, here's what we can find in the HealthCheck Startup.cs source code:
// ...
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days....