Why does Asp.Net Core 2.1 WebApi return a 500.19 error?

独自空忆成欢 提交于 2021-02-04 19:40:09

问题


I have a small webapi service, which works under Visual Studio but doesn't work under IIS. I did the next:

  1. New application was added to the default web-site in IIS console.
  2. Application was published into app folder from VS via File System (Framework-dependent and Portable options were selected).

When I try access folder with my app (like http://localhost/example/) I receive 500.19 error with code 0x8007000d. I read this error can happen if ApplicationHost.config or Web.config has wrong XML options. I use default Web.config file (ApplicationHost.config is not used by me) which VS generate, and I don't understand what can be bad in it. Here's my Web.config file:

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

回答1:


Lex Li wrote an excellent article: https://blog.lextudio.com/the-horrible-story-of-publishing-net-core-web-apps-for-beginners-6121662dd8c4, which described issues with publishing .NET Core Web Apps.

In my case, I hadn't installed the ASP.NET Core Hosting Bundle. A simple solution which is hard to be found because it is difficult to understand what should be searched for.




回答2:


I ran into the exact same issue and in addition to the marked correct answer, this is what worked for me:

I installed the ASP.NET Core Hosting Bundle and was still receiving the same error.

Repairing the installation resolved my issue.

Programs and Features -> Repair "Windows Server Hosting"

"If the Hosting Bundle is installed before IIS, the bundle installation must be repaired. Run the Hosting Bundle installer again after installing IIS. If the Hosting Bundle is installed after installing the 64-bit (x64) version of .NET Core, SDKs might appear to be missing (No .NET Core SDKs were detected). To resolve the problem, see Troubleshoot ASP.NET Core projects." - Install the .NET Core Hosting Bundle



来源:https://stackoverflow.com/questions/52916623/why-does-asp-net-core-2-1-webapi-return-a-500-19-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!