ASP.NET 核心 API - 500 内部服务器错误,仅限生产

ASP.NET Core API - 500 internal server error,only on production

我开发了一个 ASP.NET WebApi 应用程序。 当我将它发布并测试到本地主机 IIS 时,我在一个请求中遇到了这个错误:

   Response with status: 500 Internal Server Error for URL: 
http://localhost/api/COMI/NEW/158/3

web.config:

      <?xml version="1.0" encoding="utf-8"?>
        <configuration>
          <system.webServer>
            <handlers>
              <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" 
    resourceType="Unspecified" />
            </handlers>
            <aspNetCore processPath="dotnet" arguments=".\POSweb.dll" 
stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
          </system.webServer>
        </configuration>
        <!--ProjectGuid: 5f28b9b3-0e00-439a-8fa1-e64186505b5e-->

运行 IDE 没有错误 point.How 我可以 fix/debug 这个吗?

路线配置:

 app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");

                routes.MapSpaFallbackRoute(
                    name: "spa-fallback",
                    defaults: new { controller = "Home", action = "Index" });
            });

谢谢

您需要启用 stdoutlogenabled 并在您的根目录中创建一个日志目录以获取 aspnet 核心日志以解决实际错误...更多信息请点击此处

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

  <!--
    Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
  -->

  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
  </system.webServer>
</configuration>

我已经使用 TryParseExact 解决了 like there