EnvironmentName
doesn’t control, or get controlled by, the build type, it just tells you what the name of the environment is that you are currently running in.
If you want to control the actual build type use the “Solution Configurations” menu from the toolbar, or by right clicking on the solution in the Solution Explorer and choosing “Properties”
The actual EnvornmentName
property can come from multiple sources, including environment variables, and launchSettings.json
. If it isn’t configured, it will default to Production
.
launchSettings.json
with the Environment set to Development
:
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:31746",
"sslPort": 44369
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WebApplication1": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
This can also be set from the GUI by right clicking on the project, choosing “Properties”, navigating to the “Debug” tab, and setting the “Environment variables” options there.
Full documentation can be found here: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-3.1
CLICK HERE to find out more related problems solutions.