如何确定500错误的原因

时间:2017-04-08 20:39:32

标签: asp.net .net reactjs iis asp.net-core

我使用IIS Express和我制作的ASP.NET Core应用程序。在我最近的变更集中,我开始

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

在客户端。我可以在事件查看器中做任何事情,服务器日志也不能给我任何有用的信息

#Date: 2017-04-08 04:24:20
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2017-04-08 04:24:20 ::1 DEBUG / - 60372 - ::1 - - 200 0 64 19049
2017-04-08 04:24:28 ::1 GET / - 60372 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/56.0.2924.87+Safari/537.36 - 200 0 0 23321
2017-04-08 04:24:30 ::1 GET /js/tutorial.jsx - 60372 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/56.0.2924.87+Safari/537.36 http://localhost:60372/ 404 0 0 2764
2017-04-08 04:24:49 ::1 GET /comments - 60372 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/56.0.2924.87+Safari/537.36 - 200 0 0 341
2017-04-08 04:25:02 ::1 GET / - 60372 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/56.0.2924.87+Safari/537.36 - 200 0 0 580
2017-04-08 04:25:02 ::1 GET /js/tutorial.jsx - 60372 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/56.0.2924.87+Safari/537.36 http://localhost:60372/ 404 0 0 1026
#Software: Microsoft Internet Information Services 10.0
#Version: 1.0
#Date: 2017-04-08 04:36:21
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2017-04-08 04:36:21 ::1 DEBUG / - 60372 - ::1 - - 200 0 64 20554
2017-04-08 04:36:30 ::1 GET / - 60372 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/56.0.2924.87+Safari/537.36 - 200 0 0 25434
2017-04-08 04:36:34 ::1 GET /js/tutorial.jsx - 60372 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/56.0.2924.87+Safari/537.36 http://localhost:60372/ 404 0 0 3737
#Software: Microsoft Internet Information Services 10.0
#Version: 1.0
#Date: 2017-04-08 04:38:28
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2017-04-08 04:38:28 ::1 DEBUG / - 60372 - ::1 - - 200 0 64 9241
2017-04-08 04:38:38 ::1 GET / - 60372 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/56.0.2924.87+Safari/537.36 - 200 0 0 16824
2017-04-08 04:38:43 ::1 GET /js/tutorial.jsx - 60372 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/56.0.2924.87+Safari/537.36 http://localhost:60372/ 200 0 0 6067
#Software: Microsoft Internet Information Services 10.0
#Version: 1.0
#Date: 2017-04-08 04:41:07
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2017-04-08 04:41:07 ::1 DEBUG / - 60372 - ::1 - - 200 0 64 27826
2017-04-08 04:41:20 ::1 GET / - 60372 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/56.0.2924.87+Safari/537.36 - 200 0 0 38678
2017-04-08 04:41:34 ::1 GET /js/tutorial.jsx - 60372 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/56.0.2924.87+Safari/537.36 http://localhost:60372/ 200 0 0 12721
#Software: Microsoft Internet Information Services 10.0
#Version: 1.0

我发现,如果我从@Url.Content("~/js/tutorial.jsx")

注释掉Index.cshtml
@{
    Layout = null;
}
<html>
<head>
    <title>LRC Archive Dashboard</title>
</head>
<body>
    <div id="content"></div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.3.2/react-dom.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/remarkable/1.7.1/remarkable.min.js"></script>
    <script src="@Url.Content("~/js/tutorial.jsx")"></script>
</body>
</html>

我的变更集是https://github.com/jamkin/archivedash/commit/6bde62f9c85d3e8b0e32d1fb83e5737f91050e0e,而且在此之前它正在运作。

我已经通过Startup.cs和我的控制器(当我访问该页面时会进行实例化)进行调试,并且没有例外。

有人可以帮助我指出问题的方向吗?

1 个答案:

答案 0 :(得分:0)

由于错误&#34;无法加载资源:服务器响应状态为500(内部服务器错误)&#34;是从客户端,您是否能够查看开发人员工具栏网络选项卡,以查看服务器的详细错误响应。

在您粘贴的IIS日志中,我没有看到500响应状态。由于您正在使用localhost(从iis日志中找到它),因此服务器应该发送详细的错误响应以及堆栈和其他详细信息。希望您已按照说明here

在Configure方法中启用了添加开发人员例外页面
if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }

在您的客户端,您可以结帐开发人员工具栏 - >网络标签 - >点击500错误 dev toolbar response in IE

您可以在IE / Chrome / Firefox等中看到类似的响应详情