We have multiple websites based on ASP.NET Core 2.2 (before ASP.NET 3.0 formally releasing). We have chosen a great ASP.NET hosting provider that can provide a newer ASP.NET and ASP.NET Core versions, the provider is just SmarterASP.NET.
However, when we used SmarterASP.NET in the early days, we encountered a problem multiple times: After we deployed our project, we got “HTTP Error 500.0 - ANCM In-Process Handler Load Failure” error, the website could not be visited.
How to resolve the issue of HTTP Error 500.0 - ANCM In-Process Handler Load Failure?
We solved this problem with the following steps:
1: In Visual Studio, right-click on our project name, select “Edit Project File”;
<PropertyGroup> <TargetFramework>netcoreapp2.2</TargetFramework> <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> </PropertyGroup>
<PropertyGroup> <TargetFramework>netcoreapp2.2</TargetFramework> <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel> </PropertyGroup>
Or, just simply remove:
Then we can publish the project now to deploy to SmarterAsp.net hosting, the website should be opened successfully.
If we do not change the project file, we will have to change weg.config file in the published folder, we need to change 2 places - removing the hostingModel=“InProcess” and updating the modules=" AspNetCoreModuleV2" to modules=“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=".\xxxxx.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" /> </system.webServer> </location> </configuration>
Why we have to change “AspNetCoreHostingModel”?
ANCM means “Asp Net Core Module”.
We know the classic ASP.NET application based on .NET Framework is hosted inside of an IIS worker process which is the IIS Application Pool, but before ASP.NET Core 2.2, an ASP.NET Core application doesn't run in-process to the IIS worker process, but rather runs as a separate, out of process Console application runs its own Web server using the Kestrel. Kestrel is a cross-platform web server for ASP.NET Core. Kestrel is the web server that's included by default in ASP.NET Core project templates (check here).
Asp.net core 2.2 introduces a new module (aspNetCoreModuleV2) for hosting ASP.NET Core application in IIS. This new module adds the ability to host your .NET Core application within the IIS worker process and avoids the additional cost of reverse-proxying your requests over to a separate dotnet process.
However, looks like SmarterAsp.net hosting does not support Asp.Net 2.2 with In Process hosting model in IIS (at least at present), but they just supports hosting model in Kestrel, so we remove “