【发布时间】:2015-09-14 20:08:45
【问题描述】:
在尝试调试 AJAX 错误时,我决定在我的 web.config 中关闭 customErrors。结果是错误部分的 responseText 包含我需要的详细消息。因此,当 customErrors 开启时,responseText 是空白的。
有没有办法防止 responseText 为空白但仍然在 web.config 中使用 customErrors?
与该主题最接近的类似帖子是this link that says instead custom error filters might be the better solution
这是我的简单代码:
<customErrors mode="On" defaultRedirect="~/errorpage.html" redirectMode="ResponseRewrite">
<error statusCode="404" redirect="~/filenotfound.htm" />
</customErrors>
然后这里是在我关闭 customErrors 之前没有显示消息的错误处理:
error: function (xhr, status, error) {
console.log('error called');
console.log('status = ' + status + ' error= ' + error);
console.log('xhr.responseText = ' + xhr.responseText);
alert(xhr.status);
alert(xhr.responseText);
},
【问题讨论】: