2
votes

I'm a newbie learner of ASP.NET. I was following along this ASP.NET Razor pages tutorial and deployed my app to Azure.

But when I'm trying to access this Movies page, I'm getting this error.

Error.

An error occurred while processing your request.

Request ID: | f9ecac03-478613f8cb88adc0.

Development Mode Swapping to the Development environment displays detailed information about the error that occurred.

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 this existing solution and changed the mode to production but the problem remained the same.

Here is my launch setting -

{
  "iisSettings": {
    "windowsAuthentication": false, 
    "anonymousAuthentication": true, 
    "iisExpress": {
      "applicationUrl": "http://localhost:50335",
      "sslPort": 44327
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Production"
      }
    },
    "Polling_System": {
      "commandName": "Project",
      "launchBrowser": true,
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Production"
      }
    }
  }
}

My deployment mode was Framework-Dependent and later I changed it to Self-Contained.

Can anyone help me to resolve this problem? Thanks.

P.S. The page works properly on my machine if the value of "ASPNETCORE_ENVIRONMENT": is set to "Development"

1
go to your azure app settings and check the value for ASPNETCORE_ENVIRONMENT. It cannot be devThiago Custodio
Can you help me to find that setting page? There are too many options and I'm not well familiar.Mahmudul Hasan
Possible duplicate of this questionJohn Wu

1 Answers

1
votes

Update:

This is the stanard webconfig:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\OurWebApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout">
     <environmentVariables>
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
      </environmentVariables>
  </aspNetCore>
  </system.webServer>
</configuration>

Solution:

Add or change the ASPNETCORE_ENVIRONMENT setting of your web.config.

As the error says,

The Development environment shouldn't be enabled for deployed applications.

So please change it to other env. I am sorry. Answered wrong just now.

Have look of this:

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-3.1#environments

Add these code in Web.config or change the value in webconfig.(under site/wwwroot on Kudu):

<environmentVariables>
     <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="[Other env instead of Development]" />
</environmentVariables>

Your Kudu page should be: https://[yourwebsitename].scm.azurewebsites.net/DebugConsole

(Change the [yourwebsitename] to your website name and then you will go to kudu)

Don't forget to save the edit. This should work without restart.