The Development environment shouldn't be enabled for deployed applications

Viewed 1730

I get the following error when launching program:

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

I've tried solving it by setting the environmental variables to production. Not sure what is wrong. I've never had this issue before either. Previous versions worked. The only difference is I moved to a new PC. But it's the same repository.

Here is the web.config file

<?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-->

This is my launch settings:

 {
  "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"
      }
    }
  }
}

I've removed the app.UseDeveloperDebug().

1 Answers

I was able to make it work, however, if you are having the same issue what you need to understand first is that the screen you are seeing is because it there is an error in your program, since you are not in development mode it displays that screen by default.

Meaning to fix it you have to fix the error first. However, in debug mode it can still work while failing once published. To see the exact issue you can open the windows Event Viewer > Windows Logs > Application and you can see the error there.

Related