No matter when or where I set either ASPNET_ENV
or Hosting:Environment
the startup code will always enter
//This method is invoked when ASPNET_ENV is 'Production'
//The allowed values are Development,Staging and Production
public void ConfigureProduction(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(minLevel: LogLevel.Warning);
Configure(app);
}
What I've tried so far
Hosting:Environment
to Development
in the project propertiesASPNET_ENV
to Development
in the project propertiesHosting:Environment
to Development
in launchSettings.json
ASPNET_ENV
to Development
in launchSettings.json
ASPNET_ENV
to Development
in code via Environment.SetEnvironmentVariable("ASPNET_ENV", "Development");
in the Startup
method before the call to ConfigurationBuilder.GetEnvironmentVariables()
This is version 1.0.0-rc2-20143
by the way. Am I missing something here or is it just a bug?
ASP.NET Core apps configure and launch a host. The host is responsible for app startup and lifetime management. At a minimum, the host configures a server and a request processing pipeline. The host can also set up logging, dependency injection, and configuration.
Built-In Environments in . When checking the ASP.NET core project template, you should see that the “ASPNETCORE_ENVIRONMENT” variable with the value “Development” is set by default. Those are three values that are used by convention: Development, Staging, and Production.
If you need to check whether the application is running in a particular environment, use env. IsEnvironment("environmentname") since it will correctly ignore case (instead of checking if env. EnvironmentName == "Development" for example).
The environment variable name has been changed to ASPNETCORE_ENVIRONMENT
as part of the name change.
It was announced in this issue and change in this PR.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With