How to fix "HTTP Error 500.0 - ANCM In-Process Handler Load Failure"

This post shows you How to fix "HTTP Error 500.0 - ANCM In-Process Handler Load Failure" when deploying your ASP.NET Core on IIS.
HTTP Error 500.0 - ANCM In-Process Handler Load Failure

Troubleshooting steps:

Check the system event log for error messages

Enable logging the application process' stdout messages

Attach a debugger to the application process and inspect

Open you Web.config

<?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=".\ERegist.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
    </system.webServer>
  </location>
</configuration>

Next, change AspNetCoreModuleV2 to AspNetCoreModule

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath=".\ERegist.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
    </system.webServer>
  </location>
</configuration>