Setting environment variable


#1

Hi!

I have a simple ASP.NET Core project and I want to use two different connectionstrings, one for Development and one for Production.
But I cant figure out where to define if the application is in Development or Production. Is there a file where I can set ASPNETCORE_ENVIRONMENT variable? Cause I cant find a file with this defined.

Thanks!


#2

Hi Stein,

Please use two appSettings file. One for development and one for development and one for Production. Then add all appSettings.JSON file in this order

  1. Generic
  2. Production
  3. Development

while deploying to production just exclude de appSeeting at either at your CI/CD or manually.

Morever this link should help you


.NET Foundation Website | Blog | Projects | Code of Conduct