Reputation: 3085
I am having trouble changing the publish variable within web.config
because it amounts to nothing.
Once I set the variable in web.config
to Development
, for example, when I launch the application, it still says that the environment variable is Production
.
As you can see below, the web.config
states that I have set the variable to Development
.
I am out of ideas and genuinely unsure whether variables can be set this way anymore.
Upvotes: 2
Views: 910
Reputation: 388303
Looking at your first screenshot, it looks like you are running your application from the command line, probably using dotnet run
. In this case, you should note that the web.config
is completely ignored.
The web.config
is only to configure IIS for when you actually deploy your application on IIS. If you run it in any other way, the web.config
is not being used and you will have to configure the environment in a different way.
If you want to run the application from the command line, you can set the environment variable using set
:
set ASPNETCORE_ENVIRONMENT=Development
dotnet run
If you use a standard ASP.NET Core template, there should also be a launchSettings.json
file which configures the default launch settings. If you specify the environment there, dotnet run
will automatically pick it up when you run the application from the application’s root directory.
Upvotes: 1