首页 > 解决方案 > 在 Windows Server 上调用 ASP.NET Core 2.1 Web API 时出现“500 - 内部服务器错误”

问题描述

我有一个 ASP .Net Core 2.1 Web API,我已将它部署到我们最近购买的新服务器(运行 Windows Server 2016 Standard)。该 API 在我的开发 PC 和我们的旧服务器(运行 Windows Server 2012 R2)上都能完美运行。但是在这个新服务器上,我收到了这个错误:

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

我记得一年前我也在努力让它在我们的旧服务器上运行。我最终确实让它工作了,但我不记得我做了什么!有没有办法获得有关此错误的更多信息?我检查了新服务器上的 Windows 事件查看器,但那里什么也没有。此外,虽然我的web.config中有stdoutLogEnabled="true",但它没有生成日志 - 我已经创建了\logs\stdout路径,因此文件夹确实存在......

我也有app.UseDeveloperExceptionPage(); 在我的Startup.cs中,但我没有得到更多关于简单的 500 内部服务器错误的信息。

这就是我的 web.config 的样子:

<?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=".\PropWorx.API.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: cfa62a1f-c5f6-43f8-bcbe-04068e40b803-->

我还安装了Microsoft .NET Core 2.1.1 - Windows Server HostingMicrosoft .NET Core Runtime - 2.1.1(x86 和 x64)。

就像我说的那样,它可以在我的开发 PC 和我们的旧服务器上运行,所以它一定是新服务器上的配置问题。除了 500 Internal Server Error 之外,还有什么方法可以获得更详细的错误信息?

标签: asp.net-coreiisasp.net-core-webapiasp.net-core-2.1kestrel

解决方案


我有一个过时版本的 .NET Core Windows Server Hosting 包。我安装了 2.1.1 版。我删除了它,并安装了 2.1.4 版,现在它可以工作了。


推荐阅读