无法查看Internal Server 500错误的详细错误

时间:2015-04-09 21:20:13

标签: .net iis asp.net-web-api

我在IIS7.5中运行Microsoft ASP.NET Web API 2.1应用程序,我得到了通用:

  

500 - 内部服务器错误。

     

您要查找的资源存在问题,无法显示。

我已尝试以下方法来获取有关实际错误的更多详细信息,但到目前为止,请面对:

  • 设置 GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
  • 已添加<system.webserver> <httperrors existingresponse="PassThrough"/> </system.webserver>
  • 检查Windows事件日志中是否有未处理的异常,但没有
  • 添加了ExceptionLogger,但日志文件中没有任何内容:

    public class Log4NetExceptionLogger : ExceptionLogger
    {
       private readonly ILog _log = LogManager.GetLogger(typeof(Log4NetExceptionLogger));
    
       public override void Log(ExceptionLoggerContext context)
       {
          _log.Error("An unhandled exception occurred.", context.Exception);
          base.Log(context);
       }
    }
    
  • 已添加

    <configuration> <system.webServer> <httpErrors errorMode="Detailed" /> <asp scriptErrorSentToBrowser="true"/> </system.webServer> <system.web> <customErrors mode="Off"/> <compilation debug="true"/> </system.web> </configuration>

  • 在本地浏览并在IE中获取“此页面无法显示”,其绑定不是localhost

我在IIS日志中看到了500个响应,但没有详细说明错误。

1 个答案:

答案 0 :(得分:1)

为您的网站创建对localhost的绑定,并导航到服务器上的Web浏览器中的http://localhost

由于请求来自localhost,IIS将在浏览器中显示错误详细信息。

不是一个很好的解决方案,但是到目前为止我发现的速度最快。