How to set Environment Name (IHostingEnvironment.EnvironmentName)?

后端 未结 11 977
耶瑟儿~
耶瑟儿~ 2020-12-04 16:06

Default ASP.NET Core web project contain such lines in Startup.cs:

if (string.Equals(env.EnvironmentName, \"Development\", StringComparison.Ordi         


        
11条回答
  •  忘掉有多难
    2020-12-04 17:01

    In ASP.NET Core RC2 the variable name is has been changed to ASPNETCORE_ENVIRONMENT

    e.g. In Windows you can execute this command on the staging server (with admin rights)

    SETX ASPNETCORE_ENVIRONMENT "Staging" /M
    

    This only has be be executed once and after that, the server will always be considered as the staging server.

    When you do a dotnet run in the command prompt on that server you will see Hosting environment: Staging

提交回复
热议问题