77

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>
Dale K
  • 25,246
  • 15
  • 42
  • 71
Mark
  • 1,057
  • 1
  • 7
  • 14
  • Can you run a report and edit your question to include the info? https://docs.jexusmanager.com/tutorials/ancm-diagnostics.html – Lex Li May 01 '19 at 17:24
  • Can you post the web.config file in its entirety for the web/api project you are trying to run? – Phillip Copley May 01 '19 at 18:25
  • [Azure]: HTTP Error 500.0 – ANCM In-Process Handler Load Failure https://devsdaily.com/http-error-500-ancm-in-process-handler-load-failure/ – Sunny Sharma Jun 04 '19 at 07:33
  • Possible duplicate of [Using .netcore 2.2 and using the \`In Process\` Hosting Model](https://stackoverflow.com/questions/53811569/using-netcore-2-2-and-using-the-in-process-hosting-model) – Henke Oct 11 '19 at 09:59
  • Remove or comment the lastly modified code from your solution and run the application. It works fine after that. Cheers. – Nirmal JeyaChandra Apr 12 '21 at 14:05

26 Answers26

88

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.

Arif
  • 6,094
  • 4
  • 49
  • 81
  • 2
    Note: in the great "More details" link above, there is one reply about how this is setting back to out of process. This is obscured, and may not be desired. https://github.com/dotnet/aspnetcore/issues/6111#issuecomment-451294361 – goodeye Mar 11 '20 at 02:11
  • 3
    any ideas what is AspNetCoreModuleV2 vs AspNetCoreModule? – mko Mar 19 '20 at 10:19
  • Perfect solution !! – Raju Paladiya Mar 31 '20 at 12:22
  • 4
    But there is one issue whenever I publish it changes the web webconfig file every time. – Alamzaib Farooq Apr 01 '20 at 15:20
  • @goodeye To add to that, out-of-process hosting worsens performance. I.e....doing what this answer says to do will make your site slower. – Eric Eskildsen Apr 23 '20 at 16:21
  • 2
    I literally just got the latest bits from Microsoft and this is STILL a problem. This solution fixes the issue. – Kevon May 26 '20 at 20:01
  • Any idea how to update this in an Azure WebApp? I get this problem when hosting BlazorClient app where there was a BlazorServer app. Apparently they depend on different hosting configurations. – Mark Clark Jul 29 '20 at 18:48
  • @MarkClark Connect your WebApp using any [ftp client like FileZilla](https://i.imgur.com/9co0VqK.png) you should get the same `web.config` file. Though I am not familiar with Blazor, but it should work. – Arif Jul 31 '20 at 05:07
  • I found out my issue was unrelated to the above answer. It was because of the Identity Key type being undefined. – Mark Clark Aug 03 '20 at 22:29
  • 1
    Thanks, this solution works with Plesk control panel. – Ehsan Ehsani Nov 24 '20 at 19:49
  • I got this error while using VS 2019. I did remove the V2 and it worked but I also noticed that VS was warning on the value for hostingModel in the web.config. Instead I kept the V2 but changed the hostingModel from InProcess to inprocess (all lowercase) and it worked. – Mark Jun 10 '21 at 16:16
  • 2
    this worked for hosting a .NET 5 app in a Windows Server 2008 – Caio César S. Leonardi Jun 23 '21 at 23:37
20

Open the .csproj file and under Project > PropertyGroup > AspNetCoreHostingModel, change the value “InProcess” to “OutOfProcess”.

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>

Alamgir
  • 686
  • 8
  • 14
12

Sometimes this is because multiple applications may be using same Application Pool

In such cases first application will work and other won't work

Solution is to create new application pool for each application.

codemirror
  • 3,164
  • 29
  • 42
  • 3
    You catch the actual problem. – Nripendra Ojha Feb 20 '20 at 06:35
  • 1
    Yes this is the issue. The answer above by @Arif does appear to solve the issue but can mask the actual issue which is multiple web apps using the same application pool. – takesides Mar 30 '20 at 17:02
  • 1
    Might be coincidence but this only happened since I upgradedt from .net core 2.1 to .net core 3.1. Before that I could host mutiple apps in the same appool – Mathias F Feb 24 '21 at 14:19
  • 1
    this answer and the one Arif gave are indirectly triggering a restart of the process. In Arif's case changing web.config triggers a process restart in the background, same way changing application pool will simply trigger a restart. – Kalpesh Popat Jan 09 '23 at 09:42
  • @MathiasF this happened in 2.2 as well – codemirror Jan 10 '23 at 14:28
11

I had the same error.

According to Microsoft(https://dotnet.microsoft.com/download/dotnet-core/current/runtime), We should install the 'ASP.NET Core Hosting Bundle' in our hosting server.

'The ASP.NET Core Hosting Bundle includes the .NET Core runtime and ASP.NET Core runtime. If installed on a machine with IIS it will also add the ASP.NET Core IIS Module'

After I did, The 'AspNetCoreModuleV2' installed on my server and everything works well. It didn't need to change your 'web.config' file.

user2760293
  • 111
  • 1
  • 4
7

For more info, in web.config, set

stdoutLogEnabled="true"

then check the logs folder. In my case it had nothing to do with project, publishing or hosting settings - it was my fault for not copying a file essential to my app. The error was simply "Could not find file "D:\Development\IIS Hosting Test\filename.ext"

Alex Cooper
  • 475
  • 3
  • 7
  • 18
  • Simple and so true :). – joakimja Jan 16 '20 at 12:24
  • The logs folder at the root of the web api - see this - https://stackoverflow.com/questions/40536073/where-do-logs-go-when-running-asp-net-core-on-iis-7-5 "You must make sure the log folder exists! IIS won't make it for you. Such a simple solution to this infuriating problem." – Alex Cooper May 07 '20 at 17:19
2

For my particular issue it was the site permissions in IIS.

I edited the permissions to "Everyone" and it worked. I got the information from this page: https://github.com/aspnet/AspNetCore/issues/6111

Mark
  • 1,057
  • 1
  • 7
  • 14
1

I belive that IISExpress got messed up along the way.

Try the following:

'Clean Solution' from VS
Got to the solution folder and delete the .vs folder from there.
Build and run.

chapas
  • 65
  • 1
  • 5
1

I faced with the same issue today, installing the following package on server is fixed the issue for me. If you have any previous version of Windows Hosting Bundle already installed on the server, you install the new one without restarting the server.

ASP.NET Core 3.1 Runtime (v3.1.11) - Windows Hosting Bundle

zalpivan
  • 9
  • 1
  • 1
0

In my case updating .net core sdk works fine.

0

I fixed this here Asp.Net Core Fails To Load - you need to specify that the program uses an in process or out of process model.

I changed my CreateWebHostBuilder to:

public static IWebHostBuilder CreateWebHostBuilder(string[] args) 
{
    var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
    var builder = WebHost.CreateDefaultBuilder(args);

    if (env == EnvironmentName.Staging || env == EnvironmentName.Production)
        builder.UseIIS();

    builder.UseStartup<Startup>();
    return builder;
}

PS. I set ASPNETCORE_ENVIRONMENT in my .pubxml deployment profile by adding:

<PropertyGroup>
    <EnvironmentName>Staging</EnvironmentName>
</PropertyGroup>
Tieson T.
  • 20,774
  • 6
  • 77
  • 92
Liam
  • 5,033
  • 2
  • 30
  • 39
0

You can get this if you try to access the site using a IIS url but Visual Studio is setup to use IISExpress

See also ASP.Net Core 1.0 RC2 : What are LAUNCHER_PATH and LAUNCHER_ARGS mentioned in web.config?

Long story short, the web.config is changed by Visual Studio when you switch between IIS and IISExpress. If you use an IIS url when it's setup to use IISExpress then the aspNetCore processPath will be wrong

Also, it's not uncommon to copy web.config files. You could get the same error if you don't change the processPath

tony
  • 2,178
  • 2
  • 23
  • 40
0

For me it was because I had ASPNETCORE_ENVIRONMENT environment variable being defined 2 times in my app - one in web.config and another - in applicationhost.config

0

In my case just adding MVC into Startup.cs Please follow into image. I am trying to add dependency injection then showing this problem. I think it will be helpful. Follow this Image: https://i.stack.imgur.com/ykw8P.png

0

Delete the 'hosting Model ="in process"' section in web config.

Example:

<aspNetCore processPath="dotnet" arguments=".\WebAPICore.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />

to

<aspNetCore processPath="dotnet" arguments=".\WebAPICore.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
miragessee
  • 313
  • 1
  • 4
  • 14
0

I'm also getting "HTTP Error 500.0 - ANCM In-Process Handler Load Failure"

Except in my case...Everything was running great until I got the Blue Screen of Death.

I have a solution with two startup projects.
One is an API (that comes up) and the other is a WebApp(which gets the error). Both are .NET Core 3.1..also VS2019.

First I tried setting a break point in Main() of program.cs...it never got this far.

 public static void Main(string[] args)
 {
     CreateHostBuilder(args).Build().Run();
 }

On a hunch...I Looked at the NuGet packages installed. I uninstalled and (re)installed

Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation(3.1.6)

...and now its working again.

Chris Catignani
  • 5,040
  • 16
  • 42
  • 49
0

In case anyone else cannot find a solution to this here was my scenario:
I recently started a new project using .NET 5, and everything was working. Then I upgraded from Preview 5 to 7 and all of a sudden my IIS Express would no longer work. The fix for me was to simply repair Visual Studio:

VS 2019 Repair.

de.
  • 7,068
  • 3
  • 40
  • 69
0

This happened to me when I switched form debugging in IIS Express to IIS. I inspected Event Viewer > Application log, and found the following error there:

Executable was not found at '...\bin\Debug\netcoreapp3.1\%LAUNCHER_PATH%.exe'

I then found the solution to that in the following thread.

I basically needed to replace web.config entry with hard-coded name of the application:

<aspNetCore processPath="dotnet" arguments=".\ProjectName.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
Eternal21
  • 4,190
  • 2
  • 48
  • 63
0

I get that error when i try to get data from the ViewModel as List<> and my data is coming as IEnumerable format. Before u guys update your vs2019 or delete some files,u should better to check it out that option.

BerkGarip
  • 534
  • 5
  • 18
0

For me it was caused by different web.config files for development and deployment :

development: <aspNetCore requestTimeout="23:00:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" forwardWindowsAuthToken="false" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" startupTimeLimit="3600" hostingModel="InProcess">

deployment : <aspNetCore requestTimeout="23:00:00" processPath=".\Nop.Web.exe" arguments="" forwardWindowsAuthToken="false" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" startupTimeLimit="3600" hostingModel="InProcess">
Steef
  • 569
  • 5
  • 21
0

In my case, I put app_name.exe back from my backup folder to bin\debug, and boom it worked.

If you don't have a backup folder that contains exe so don't worry publish your web app / web API and copy from there

0

No previous answers worked for me. In my case the "processPath" inside "aspNetCore" tag was pointing to a non-existing folder. A colleague told me that when any value in the web.config is wrong the app doesn't start and emerge this weird error.

0

In my case, after updating to .Net 6 and using a self contained application I started seeing this error.

I could manually set the module to AspNetCoreModule and the application would run in IIS but I knew this was just a work around since AspNetCoreModuleV2 should be used with .Net 6 applications

I had the following line in the ConfigureServices method:

services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

Removing the compatibility version resolved my issue.

services.AddMvc();

Digbigpig
  • 66
  • 3
0

This is a temporary problem caused by changes in folder or host settings while the application was running.

Most solutions provided here are working because they are indirectly triggering a restart. eg: Changing web.config will trigger a process cleanup and restart for that app.

Solution: Is restart the application process

If the problem still persist after the restart then check EventViewer to see the actual problem, a persistent problem usually means your application has a bug.

Kalpesh Popat
  • 1,416
  • 14
  • 12
-1

I tried changing aspnetCoreModuleV2 to aspnetCoreModuleV2, which worked, but it was a hassle to change every time I published it in Visual Studio. After testing, I found that I could change the application pool default Settings for IIS to enable 32-bit applications in general.

But I haven't tested it on a 32-bit computer, it should be OK.

See Screenshot.

Gerard de Visser
  • 7,590
  • 9
  • 50
  • 58
-1

Fixing all project build errors, would simply fix this issue & the application will load.

Sanushi Salgado
  • 1,195
  • 1
  • 11
  • 18
-2

Change platform target to Any CPU.

Change platform target to Any CPU

4b0
  • 21,981
  • 30
  • 95
  • 142
Majid gharaei
  • 281
  • 3
  • 11