dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.47k stars 10.03k forks source link

HTTP Error 500.31 is rather unhelpful #46021

Closed Montago closed 1 year ago

Montago commented 1 year ago

Is there an existing issue for this?

Describe the bug

I've been developing a .NET 6/7 WebAPI site and ran into a HTTP Error 500.31 error when hosting the site in IIS.

more specifically IIS reports this error page:

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.

The ACTUAL problem i had, was that the Web.Config was referencing an incorrect DLL :

the 500.31 error suggest that the framework installation on the host machine is to blame, which sends the developer out on the wrong direction of problem solving.

Expected Behavior

I would expect a better error message, that the Path of the DLL (the argument) is incorrect.

It shouldn't be that hard for dotnet.exe to tell me that the argument is wrong.

Steps To Reproduce

<?xml version="1.0" encoding="utf-8"?>
<configuration>

<location path="." inheritInChildApplications="false">
    <system.webServer>
        <handlers>
            <add name="aspNetCore"
                 path="*"
                 verb="*"
                 modules="AspNetCoreModuleV2"
                 resourceType="Unspecified" />
        </handlers>
        <aspNetCore processPath="dotnet"
                    arguments=".\INCORRECT-NAME-OF-DLL.dll"
                    stdoutLogEnabled="true"
                    stdoutLogFile=".\logs\stdout"
                    hostingModel="inprocess" />
    </system.webServer>
</location>
</configuration>

Exceptions (if any)

No response

.NET Version

6 or 7

Anything else?

No response

BrennanConroy commented 1 year ago

The error has improved to point you at the application name likely being wrong now.