1
votes

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!

1
@cleftheris Thanks! as per the above link I added the below settings in launchsettings.json jsoneditoronline.org/?id=da032fc0d3ef4fc9a1d75bc88b1f7c18Kgn-web
@cleftheris but when added, its throwing runtime error 500 - The requested address is not valid in its contextKgn-web
launchSettings.json is only used by dotnet run ( i.e. inside Visual Studio), it's more than useless for deployment to IIS.Chris Pratt
@Kgn-web You should check the section called "set-the-environment" in the documentation above. Assuming you are running on windows according to the docs you can either. A. Set a windows global environment variable through the system settings. B. Set the environment variable through web.config. The B option is easier.cleftheris

1 Answers

2
votes

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