Reputation: 527
My launchSettings.json is :
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:65000",
"sslPort": 44367
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Portal.WebUI": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
}
}
}
Also when I right click to my Web Project in Solution Explorer my ASPNETCORE_ENVIRONMENT is set to Development.
But there is an issue,
In my startup
if (env.IsDevelopment())
{
} }
else{
}
when I put a debugger here, it goes to "else" block as if it is not set to Development environment.
So I tried another way of debugging it, and I think I know the error, but I dont know why it is happening.
So I put a line of code above my "if/else" condition which is:
var envi = env.EnvironmentName;
if (env.IsDevelopment())
{
}
else
{
}
So when I put my debugger point to "var envi" line, then "envi" variable comes "Development;Development;" but it should be only "Development".
EDIT
Now, I tried to change it to Production from right clicking to my project and set ASPNETCORE_ENVIRONMENT to "Production" now my "envi" variable is "Development;Production"
So always there is a "Development;", how can I find the issue in here..
Can you please help?
Upvotes: 1
Views: 1130
Reputation: 12381
Visual Studio caches the environment variables when it was started up - not when you hit "debug", so you may want to restart the IDE and give it one more try.
Upvotes: 1