Asp.net-core – How to fix error “ANCM In-Process Handler Load Failure”

asp.net-coreasp.net-core-2.2iis

I'm setting up the first site in IIS on Windows Server 2016 Standard.
This is a NET Core 2.2 application. I cannot get the site to show.

I am getting this error:

HTTP Error 500.0 – ANCM In-Process Handler Load Failure

What can I change to clear this error and get my site to display?

My application is a dll.

I tested my application on the server through the Command Prompt with

dotnet ./MyApp.dll

it displays in the browser but only on the server itself with (localhost:5001/).

Using this method the site cannot be accessed from any other server.
When I set up the site through IIS, I get the In-Process error both on the server and from servers attempting to access the site.

At first I was receiving the Out-Process error. Something I read said to add this (hostingModel="inprocess") to my web.config
so I did but now I receive the In-Process error.

The site works fine when installed on my development server.

The Event Viewer shows this error for "IIS AspNetCore Module V2":

Failed to start application '/LM/W3SVC/2/ROOT', ErrorCode '0x8000ffff'.

This is my web.config:

<?xml version="1.0" encoding="utf-8"?>
    <configuration>
  <system.web>
    <customErrors mode="RemoteOnly"></customErrors>
        <identity impersonate="false" password="****" userName="****" />
  </system.web>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\MyApp.dll" stdoutLogEnabled="false" hostingModel="inprocess" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false">
      <environmentVariables />
    </aspNetCore>
  </system.webServer>
</configuration>

Best Answer

I had the same issue in .Net core 2.2. When I replace

web.config:

<handlers>
    <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>

to

<handlers>
    <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>

then it works fine.

Note: The same solution also works for .Net core 2.2 and other upper versions as well.