I used angular .net core 2.2 template to build application.In localhost working fine,When i host to IIS Im getting this error.Im using IIS 10 to host the application.
<UPDATE
ORIGINAL
I got this to work by adding the following code block to the .csproj
for the web application.
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>latest</LangVersion>
<AspNetCoreModuleName>AspNetCoreModule</AspNetCoreModuleName>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>
Obviously you'll want to update the netcoreapp
version as you move on. This is how I was able to get things working. I'm not sure why simply installing the hosting bundle for 2.2 wasn't enough.
the best solution for when hosting has this problem is to override this value inside project.csproj file for release version. notice when use legacy version of module in new version of visual studio debugger not work. so the best solution is this .
<TargetFramework>netcoreapp3.1</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<AspNetCoreModuleName Condition="'$(Configuration)' == 'Release'">AspNetCoreModule</AspNetCoreModuleName>
By removing V2 from modules="AspNetCoreModuleV2" worked for me. Note that my issue was related to running a .net core web api from visual studio. IE Express failed with a code 500 and upon investigating the error log describing "Handler 'aspNetCore' has a bad module.." was resolved by replacing with the below.
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
I had .net core 2.1, webAPI using Visual Studio 2019 (Windows 10). Installed hosting bundle (3.1.3). I tried to deploy to a folder, using publish option. The files were generated. I followed quick steps to create website in IIS. However I started getting HTTP Error 500.21. finally opened web.config file from deployment folder and did the reverse - change AspNetCoreModule to AspNetCoreModuleV2. All good now. thanks for all suggestions.
I had this same issue and what worked for me was to repair the install of the hosting bundle (Control Panel -> Programs and Features; right click on the hosting bundle install and click on 'Uninstall', then select 'Repair' in one of the following window that pops up.
I'm posting my answer to save other people time who stuck with the same issue which took about 1 hour. My issue was that I installed an incorrect hosting budle. If your application uses .Net Core 3.1, you have to download it not with the link "x64", but with the link "Hosting bundle" on the next page: https://dotnet.microsoft.com/download/dotnet-core/3.1
My issue was that I thought that x64 hosting bundle is located in the link "x64" but it isn't. "x64" link doesn't contain the hosting bundle and will not solve the issue. The hosting bundle should be downloaded using only the link "Hosting Bundle":
The following article was very helpful for me to understand this issue: https://dotnetcoretutorials.com/2019/12/23/hosting-an-asp-net-core-web-application-in-iis/