1

Development Mode
Swapping to Development environment will display more 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 try publish simple application built with .NET Core MVC. I've tried replacing launchSetting.json. It's not working.

enter image description here

Harshitha Veeramalla
  • 1,515
  • 2
  • 10
  • 11
Rio Hanz
  • 11
  • 1
  • 2
  • Have you tried adding the environment variable given in the error message to your App Service to see what the problem is? – James Gould Feb 08 '22 at 15:54
  • Welcome to Stack Overflow. Please take the [tour], read [what's on-topic](https://stackoverflow.com/help/on-topic), and [ask], where there is a bullet saying, "**DO NOT post images of code, data, error messages, etc.** - copy or type the text into the question." – Heretic Monkey Feb 08 '22 at 15:55
  • Are you able to build/access the app locally ? – Harshitha Veeramalla Feb 08 '22 at 16:19
  • **Or** Go to Azure, click on your Web App –> "Applications Settings" –> go down to the “App Settings” section and check the key “ASPNETCORE_ENVIRONMENT” and value “Development” – Harshitha Veeramalla Feb 08 '22 at 16:53
  • In Startup.cs, in configure method add - **app.UseDeveloperExceptionPage();** – Harshitha Veeramalla Feb 08 '22 at 17:02

1 Answers1

1
  • You can change ASPNETCORE_ENVIRONMENT from "Production" to "Development".
  • Add ASPNETCORE_ENVIRONMENT with value: Development in Azure Portal. Go to AzurePortal => your Web App =>Configuration => "Applications Settings" => add the “ASPNETCORE_ENVIRONMENT” and “Development”
  • In Startup.cs, change the code for the Configure () method .
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseDeveloperExceptionPage();
    ...
}
  • Modify your web.config file with the below. If you dont have a web.config , add one.
<aspNetCore processPath="dotnet" arguments=".\projectName.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout">
     <environmentVariables>
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
      </environmentVariables>
  </aspNetCore>

OR The web.config in its entirety should resemble the below (update "projectName.dll" for your project appropriately):

<?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="dotnet" arguments=".\projectName.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" >
     <environmentVariables>
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
      </environmentVariables>
  </aspNetCore>
    </system.webServer>
  </location>
</configuration>

Please refer these similar issue articles A1 , A2 , A3 for more information.

Harshitha Veeramalla
  • 1,515
  • 2
  • 10
  • 11