0

Just wanting peoples opinions on how they are handling their app settings load in the program.cs.

I have setup 3 app settings in my web app one for dev, uat and Prod. At the moment the loading of these during startup is done via the environment variable. But the problem is that If I want to deploy both uat and prod to the same server then both website when deployed only ever use the prod app settings.

Has anyone run into this before and what solutions have people come up with to work around this?

Thanks

  • You can either use another provider like json file, or you can use [custom env var prefix](https://learn.microsoft.com/en-us/dotnet/core/extensions/configuration-providers#environment-variable-configuration-provider) in conjunction with checking the [hosting environment](https://andrewlock.net/how-to-set-the-hosting-environment-in-asp-net-core/#setting-hosting-environment-using-command-args) for uat or prod. No time for a proper answer but I can come back to it if needed and nobody takes care of it by then. – Crowcoder Mar 02 '21 at 22:13
  • Due to the particularity of asp.net core, its configuration file is not web.config like Asp.net application, but appsetting.json. So you can directly add all appsettings in the startup file of asp.net core .json and build. Just like these [answer](https://stackoverflow.com/a/54216774/14162739) – Bruce Zhang Mar 03 '21 at 07:14

0 Answers0