不应为已部署的应用程序启用开发环境

The Development environment shouldn't be enabled for deployed applications

启动程序时出现以下错误:

The Development environment shouldn't be enabled for deployed applications. It can result in displaying sensitive information from exceptions to end users. For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development and restarting the app

我尝试通过将环境变量设置为生产来解决它。不知道哪里出了问题。我以前也从来没有遇到过这个问题。以前的版本有效。唯一的区别是我换了一台新电脑。但它是同一个存储库。

这是 web.config 文件

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath=".\Marel.Lairage.Blazor.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" >
      <environmentVariables>
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="QA" />
      </environmentVariables>
    </aspNetCore>
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: b533d905-8294-4d2e-9445-da1d5a94cc97-->

这是我的启动设置:

 {
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:50235",
      "sslPort": 44351
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Marel.Lairage.Blazor": {
      "commandName": "Project",
      "dotnetRunMessages": "true",
      "launchBrowser": false,
      "applicationUrl": "http://*:900",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Production"
      }
    }
  }
}

我删除了 app.UseDeveloperDebug()

我能够让它工作,但是,如果你遇到同样的问题,你首先需要了解的是你看到的屏幕是因为你的程序有错误,因为你不是在开发模式下,它默认显示该屏幕。

意思是要修复它你必须先修复错误。但是,在调试模式下,它仍然可以在发布后失败时工作。要查看确切的问题,您可以打开 windows Event Viewer > Windows Logs > Application,您可以在那里看到错误。