22

I'm hosting ASP.NET Core 2 site and getting below error message.

HTTP Error 500.21 - Internal Server Error
Handler "aspNetCore" has a bad module "AspNetCoreModule" in its module list

My application is using nopCommerce 4.00 and server side already ASP.NET Core component is installed.

Weihui Guo
  • 3,669
  • 5
  • 34
  • 56
Raju Paladiya
  • 778
  • 2
  • 12
  • 35

5 Answers5

57

I was facing the same issue after following this blog on how to host an asp.net core app into IIS. Visual studio had added the following web.config in the published output folder.

enter image description here

Then I looked into my IIS module to check if the .NET core hosting bundle was installed properly and I saw this,

enter image description here

So I changed the module in web.config,

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

and it worked without any issues after that.

Zaki Choudhury
  • 1,497
  • 15
  • 6
  • 4
    this worked for me but every time I published the solution from Visual Studio it set the web.config back to modules="AspNetCoreModule" again. Since this was just a test project, I updated to the latest versions of Visual Studio and .Net core, deleted the whole project and started again and after that it worked. – Andy Nov 26 '19 at 10:51
  • This worked for me, thank you so much! @Andy, I think since I am far along in my solution I will have to manually update the web.config every single time :/ Not a big deal but certainly tedious. Hey, now I know for my next .NET Core project! – Hopper Mar 30 '20 at 19:40
  • 2
    If you don't want to manually change the web.config every time, installing an older version of the IIS hosting bundle also installs the "AspNetCoreModule" which can be installed side-by-side with V2. I installed the .Net Core 2.2 IIS hosting bundle which did it for me. – S. Rasmussen Apr 03 '20 at 13:51
12

I had the same error. The handler was AspNetCoreModule, code is %SystemRoot%\system32\inetsrv\aspnetcore.dll. Changing the handler to AspNetCoreModuleV2 with code %ProgramFiles%\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll solved the problem.

enter image description here

enter image description here

This link is also helpful. In case the link doesn't work:

This error can occur if the AspNetCoreModule is not installed properly in IIS on the computer that is running the Microsoft Dynamics NAV Web Server components. The AspNetCoreModule is installed with the Microsoft .NET Core Windows Server Hosting bundle. You can get this error if this has been not been fully installed or the installation has been damaged in some way.

To resolve this issue, open Programs and Features in Control Panel and check whether Microsoft .NET Core Windows Server Hosting is installed. Then, try one of the following:

  • If it is installed, repair it from Programs and Features, by selecting it, choosing Change, and then choosing Repair.

  • If it is not installed, download and install Microsoft .NET Core - Windows Server Hosting bundle.

Weihui Guo
  • 3,669
  • 5
  • 34
  • 56
  • 1
    Thank you for the solution. In my case the Module had AspNetCoreModuleV2 key with correct value, but aspNetCore in Handler Mapping did not have the correct value. – LastManStanding Nov 08 '19 at 18:01
5

I was having the same error, I enabled the logs in web.config file by settinig stdoutLogEnabled="true"

<aspNetCore processPath=".\site01.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />

And I found that I am missing the correct version of Microsoft.AspNetCore.App

It was not possible to find any compatible framework version
The framework 'Microsoft.AspNetCore.App', version '2.1.12' was not found.
  - The following frameworks were found:
      3.1.2 at [C:\Program Files (x86)\dotnet\shared\Microsoft.AspNetCore.App]

so i installed the ASP.NET Core 2.1 Runtime (v2.1.16) - Windows Hosting Bundle Installer from https://dotnet.microsoft.com/download/dotnet-core/2.1/runtime/?utm_source=getdotnetcore&utm_medium=referral

AND MY PROBLEM WAS SOLVED.

Community
  • 1
  • 1
Ali Shan
  • 459
  • 7
  • 14
2

I was having the same error,I change "AspNetCoreModule" to "AspNetCoreModuleV2" in web.config. work fine

Farid Savad
  • 163
  • 1
  • 11
0

This is exactly the issue that I was having.

I have posted a similar solution here, which solves a different scenario.

After installing the .NET Core Windows Hosting Bundle, and even the SDK, the AspNetCoreModule lines were still missing on applicationHost.config.

AspNetCoreModuleV2 was there, though.

So, I found an applicationHost.config in another server that had those AspNetCoreModule lines and updated the file on the broken server. Not sure why they were not being added by the .NET Core installation on that specific server.

I added the line below under the <globalModules> section:

<add name="AspNetCoreModule" image="%SystemRoot%\system32\inetsrv\aspnetcore.dll" />

And this one under <modules>:

<add name="AspNetCoreModule" />

Hope this helps.

Caio Campos
  • 339
  • 5
  • 10