'ASP.NET Core 2.0.0 Angular app showing HTTP Error 502.5 when hosted on IIS

I am stuck trying to publish this legacy project to folder, and host it on IIS locally. I get an HTTP error 502.5.

I have uninstalled all the newer SDKs and only have 2.0.0 installed at this time. I have installed webhost and runtime for .NET Core 2.0.0 and .NET 6.0.3.

I've been looking for a solution on the web indicated me that "Error 502.5" is either related to a wrong or missing SDK, or a problem with web.config.

I cannot identify any problem with the web.config (I am attaching my config file below). I created a simple ASP.NET Core 2.0 MVC project for testing and it is deploying without any error. It is a project developed by someone else and I am not wholly familiar with it, and trying to just deploy it on our local server. Any help will be greatly appreciated.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <security>
            <requestFiltering allowDoubleEscaping="false">
                <requestLimits maxAllowedContentLength="30000000" maxUrl="40960" maxQueryString="20480" />
            </requestFiltering>
        </security>
        <modules>
            <remove name="WebDAVModule" />
        </modules>
        <handlers>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
        </handlers>
        <aspNetCore processPath="dotnet" arguments=".\Web.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00">
            <environmentVariables />
        </aspNetCore>
        <httpErrors existingResponse="PassThrough" />
    </system.webServer>
</configuration>

Edit: I am including the log I found after one of the failed attempts below.

Log Name:      Application
Source:        IIS AspNetCore Module
Date:          10/03/2022 09:44:00
Event ID:      1000
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      LAPTOP-XXX-TANZIB
Description:
Application 'MACHINE/WEBROOT/APPHOST/XXXTEST' with physical root 'C:\XXX Builds\Build-3\' failed to start process with commandline 'C:\XXX Builds\Build-3\Web.exe ', ErrorCode = '0x80004005 : e0434352.
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="IIS AspNetCore Module" />
    <EventID Qualifiers="0">1000</EventID>
    <Version>0</Version>
    <Level>2</Level>
    <Task>0</Task>
    <Opcode>0</Opcode>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2022-03-10T09:44:00.9621312Z" />
    <EventRecordID>16307</EventRecordID>
    <Correlation />
    <Execution ProcessID="31784" ThreadID="0" />
    <Channel>Application</Channel>
    <Computer>LAPTOP-XXX-TANZIB</Computer>
    <Security />
  </System>
  <EventData>
    <Data>Application 'MACHINE/WEBROOT/APPHOST/XXXTEST' with physical root 'C:\XXX Builds\Build-3\' failed to start process with commandline 'C:\XXX Builds\Build-3\Web.exe ', ErrorCode = '0x80004005 : e0434352.</Data>
  </EventData>
</Event>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source