myesn

myEsn2E9

hi
github

IIS: Configure ASP.NET Core environment variables using different configuration files

Expect to use different configuration files in different environments, there are many ways to do this, refer to: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-8.0

The way I use is to configure the environment variable: ASPNETCORE_ENVIRONMENT, the default standard environment names are:

  • Development local
  • Staging testing
  • Production production

Of course, it can be set to any environment name, and their corresponding configuration files are appsettings.{Environment}.json (in today's asp.net core, the environment variable file for .AddJsonFile has been configured, no need to configure manually).

Then, because I am using IIS, the way to configure environment variables in IIS is: https://stackoverflow.com/questions/31049152/publish-to-iis-setting-environment-variable

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.