我有一个 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 Hosting 和 Microsoft .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/