How to set ASP.NET 5 environment variables on production environment

前端 未结 2 1629
后悔当初
后悔当初 2021-01-12 08:07

In Visual Studio 2015 you set the following variable in project properties: ASPNET_ENV. If you set it to development then you can use:

publi         


        
相关标签:
2条回答
  • 2021-01-12 08:25

    This is how to set the environment variable on Windows:

    1. On your server, right click 'Computer' or 'My Computer' and click on 'Properties'.
    2. Go to 'Advanced System Settings'.
    3. Click on 'Environment Variables' in the Advanced tab.
    4. Add a new System Variable with the name ASPNET_ENV (RC1) or ASPNETCORE_ENVIRONMENT (RC2, RTM and Above) and a value of Production, Staging, Development or whatever you want.
    5. A reboot of your site may be required.

    See also this answer for how to read the environment variable from gulpfile.js.

    0 讨论(0)
  • 2021-01-12 08:33

    If you are using IIS to host your application, it's possible to set the environment variables in your web.configfile like this:

    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false">
        <environmentVariables>
            <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="QA" />
            <environmentVariable name="AnotherVariable" value="My Value" />
        </environmentVariables>
    </aspNetCore>
    
    0 讨论(0)
提交回复
热议问题