asp.net-core - 在 Windows Server 上调用 ASP.NET Core 2.1 Web API 时出现 "500 - Internal server error"

标签 asp.net-core iis asp.net-core-webapi asp.net-core-2.1 kestrel

我有一个 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 路径,因此文件夹确实存在...

我的 Startup.cs 中也有 app.UseDeveloperExceptionPage();,但除了简单的 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 内部服务器错误之外,还有什么方法可以获得更详细的错误信息?

最佳答案

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

关于asp.net-core - 在 Windows Server 上调用 ASP.NET Core 2.1 Web API 时出现 "500 - Internal server error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52270350/

相关文章:

c# - 在 ASP.NET Core 7 WebApi 中使用 RouteGroupBuilder 时如何获取路由组前缀

angular - 如何保护 .net 核心 API 项目

iis - 使用IIS重写将HttpOnly标志添加到Cookie无效

c# - 如何将 int 数组 (int[]) 传递给 ASP.NET Core 中的 Get 方法

c# - 构建 asp.net core IdentityServer 用于跟踪多个经销商的用户

ASP.net Core 2.0 JWT token 刷新

c# - 如何从 asp.net 核心服务访问 DbContext

asp.net - 为什么我的 WebRole 在 WaWebHost 而不是 IIS 上运行

Microsoft Azure 上的 Python FastCGI 错误

asp.net-core-webapi - 如何在 Azure Application Insights 中获取 Web 请求的响应大小