By default, ASP.NET Core applications run in the Development environment when running within Visual Studio. I need to debug the Production environment. What is the easiest way to switch between environments?
I see the environment variable ASPNETCORE_ENVIRONMENT
is being set under my project properties. But I don't understand why it is set in two places: once for my project and once for IIS Express.
Do I need to edit both of these? Is it possible to do this from code.
I may want to switch back and forth, and I have to be sure to restore it when I'm done, so I'm looking for a simple way to set this.
I mean in the project properties window.
Those are launch profiles:
And they are controlled by launchSettings.json
located in Properties
folder of the project (see Development and launchSettings.json). The launchSettings.json
file:
You have two profiles, one launches app under IIS Express and the other uses Kestrel web server. You can the one you want. Potentially the easiest option to run and debug locally would be setting ASPNETCORE_ENVIRONMENT
to Production
and editing appsettings.json
file to contain production values (or appsettings.Production.json
so you don't need to pollute your main one, see Configuration in ASP.NET Core).