vs开发.net core一般会默认开发环境(ASPNETCORE_ENVIRONMENT:Development),但生产环境需要设置ASPNETCORE_ENVIRONMENT:Production以作区分,设置环境为生产环境有两种情况。

一、windows下设置服务器的环境变量。(我的电脑---->右键属性---->高级系统设置---->高级选择卡---->环境变量---->新建系统变量---->变量名:ASPNETCORE_ENVIRONMENT;变量值:Production)

二、配置web.confog

<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="****" arguments="" stdoutLogEnabled="false" hostingModel="InProcess">
        <environmentVariables>
          <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" />
        </environmentVariables>
      </aspNetCore>
    </system.webServer>
  </location>
</configuration>

欢迎提供其他设置方式。

posted on 2020-08-20 13:58  牟珏玘  阅读(349)  评论(0编辑  收藏  举报