Siwar Hadj Ali
Siwar Hadj Ali

Reputation: 23

How to fix HTTP Error 500.31 - Failed to load ASP.NET Core runtime

I'm trying to publish a .NET Core 5.0 application to IIS but I get an error:

HTTP Error 500.31 - Failed to load ASP.NET Core runtime

Common solutions to this issue:
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.

Troubleshooting steps:

  • Check the system event log for error messages
  • Enable logging the application process' stdout messages
  • Attach a debugger to the application process and inspect

My web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
        <aspNetCore processPath="dotnet" arguments=".\AppCore.dll" stdoutLogEnabled="false" hostingModel="inprocess" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
  </system.webServer>
</configuration>

.NET info: dotnet --info

I have installed the ASP.NET Core Runtime 5.0.17 Hosting Bundle. I need to stay on .NET 5 for now for a client's requirement.

Upvotes: 1

Views: 21639

Answers (1)

Neil W
Neil W

Reputation: 9247

There could be any number of errors during start up that is causing your problem. When I first faced this issue, enabling logging and viewing that put me in the right direction.

Enable logging by editing your deployed web.config file.

<aspNetCore processPath="dotnet" 
            arguments=".\AppCore.dll" 
            stdoutLogEnabled="true"   *** <<< change this
            hostingModel="inprocess" 
            stdoutLogFile=".\logs\stdout" 
            forwardWindowsAuthToken="false"/>

Then ...

  1. Recycle your server application
  2. Make a request to your server application
  3. This should cause the previous error
  4. Have a look on your server for log file in logs\stdout*
  5. The log file should give you some pointers
  6. If this doesn't nail it first time, you might need to add some extra logging on the server based on the pointer from step 5.

Upvotes: 5

Related Questions