s

IIS dot net 6 debug error ASPNETCORE_ENVIRONMENT environment variable to Development and restarting the app not working edit button Edit

author
Murugan Andezuthu Dharmaratnam | calendar 31 January 2024 | 60


I was trying to debug an error while developing an application in .net 6. I got this error. but after setting the environment variable to Development still I was not able to view the error details. See the solution below.

Error.
An error occurred while processing your request.
Request ID: 00-df68b81cebfbaee3faedaf5f00b134f8-e14e3022ff7ea455-00

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.

Solution

I restarted iis still It did not work. the solution was to modify the web.config file. please find below the changes to web.config I only added the environmentVariables section

    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\RigServ.Web.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" >

      <environmentVariables>
        <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
      </environmentVariables>
      </aspNetCore>
    </system.webServer>