How to set Environment Name (IHostingEnvironment.EnvironmentName)?

后端 未结 11 975
耶瑟儿~
耶瑟儿~ 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 16:58

    launchsettings.json

    At Properties > launchsettings.json

    Just like this:

        {
      "iisSettings": {
        "windowsAuthentication": false,
        "anonymousAuthentication": true,
        "iisExpress": {
          "applicationUrl": "http://localhost:1032/",
          "sslPort": 0
        }
      },
      "profiles": {
        "IIS Express": {
          "commandName": "IISExpress",
          "launchBrowser": true,
          "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Production"
          }
        },
        "WebAppNetCore": {
          "commandName": "Project",
          "launchBrowser": true,
          "launchUrl": "http://localhost:5000",
          "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
          }
        },
        "web": {
          "commandName": "web",
          "environmentVariables": {
            "ASPNETCORE_ENVIRONMENT": "Development"
          }
        }
      }
    }
    

提交回复
热议问题