HTTP Error 500.31 - Failed to load ASP.NET Core runtime
In my case, the target machine was missing the ASP.NET Core runtime itself.
Issue is resolved after installing the Hosting Bundle from .Net Core 3.1
I was getting the same error messages for a new .NET Core 3.1 framework-dependent web app on an IIS server which was already hosting other .NET Core 3.1 framework-dependent web apps with no problem. The messages in Event Viewer were slightly different; but also very hard to find - sometimes I couldn't see any events which seemed to relate.
If I converted the site to stand-alone "win-x86", it worked; but stand-alone "win-x64" didn't work.
After days of...
- Reading the information on the linked Microsoft URL in the error message,
- running the site from the command line (no problem),
- checking
dotnet --info
on the IIS server, - checking
dotnet --info
on the build server, - staring at JSON config files, project files, build settings, publish settings and IIS settings
...this turned out to be an AppPool setting.
In the AppPool's Advanced Settings, there is an "Enable 32-Bit Applications" setting, which IIS considers the default to be False; but on mine was True. Toggling this setting caused the site to work and fail, when False and True, respectively.
It had been set to True on my site because we use octopusdeploy to deploy our site, and the "IIS AppPool – Create" step has an option relating to this setting; but in Octopus, the default value is True, so this needed turning off.
Using the tool suggested (and created) by @LexLi I was able to determine the issue was caused by the application pool not having permissions to the site folder. Giving it permissions fixed the issue. This was not clear from the error messages. Answered here in case anyone else experiences the same error message.
I had the same problem...
my solution is quite simple and sort of embarrassing at the same time :) I thought asp.net core host bundles are downward compatible.
Solution: my application was configured with 3.1. as target framework but I had installed the 5.0.9 hosting bundle on the iis.
After I installed the right version of the hosting bundle, the 3.1. version, it worked!