Search code examples
c#asp.net-coreenvironment-variablesasp.net-core-2.1windows-server-2012

ASP.Net Core 2.1 ASPNETCORE_ENVIRONMENT value not reflecting


I have ASP.Net Core 2.1 API app. It is supposed to host in 4 environments.

  1. Development
  2. Testing
  3. Staging
  4. Production

When running the app in local from Visual Studio, the app is rightly fetching the ASPNETCORE_ENVIRONMENT variable & accordingly fetching the values from appsettings.Development.json

Local Dev Machine

But when the same deployed in a VM, it's not fetching the environment & looking for settings (like Connection string etc.) from appsettings.json.

Test Environment

What else settings I need to do so?

Thanks!


Solution

  • You should be setting System Environment Variable rather than User Variable.