asp.net-mvc - 即使操作中没有错误,asp.net core 也会抛出 500
问题描述
我不确定如何解决 asp.net core 2.2 操作将 HTTP 500 返回到浏览器的场景,即使它应该返回一个匹配的视图,即使它一直完成操作到返回视图() 陈述。
这是浏览器中的代码,尽管返回了视图,但我从操作中获得了 500 的内部 POST。
$.post({
url: '/Analysis/SomeOtherAction',
contentType: dataType,
data: JSON.stringify(data),
success: function (response) {
if (response.IsValid) {
if (evaluation === "1") {
$.post({
url: '/Analysis/WhyDoesThisFail',
contentType: dataType,
data: JSON.stringify(data)
});
}
else {
window.location = '/Results/Download?fileGuid=' + response.Data.FileGuid
+ '&filename=' + response.Data.FileName;
}
}
else {
$('#validationList').empty();
for (var i = 0; i < response.ValidationMessages.length; i++) {
$("#validationList").append("<li>" + response.ValidationMessages[i] + "</li>");
}
$('#modelValidationModal').modal('toggle');
}
}
});
在我的控制器中,我有:
[HttpPost]
public IActionResult WhyDoesThisFail([FromBody] SomeViewModel model)
{
// some stuff happens in here...
return View(); // I can step through all the way to this point with no errors
}
我想返回位于视图下分析文件夹中的WhyDoesTHisFail 视图。
解决方案
推荐阅读
- python - 将数据保留为 pandas 数据框中的最新日期
- java - Apache Camel 3.0.1 无法启动并消耗路由器到 FTPs 文件夹
- laravel - 可以将多字变量传递给刀片组件吗?
- python - 此代码会导致无效的语法错误。为什么?
- javascript - http模块的后端和前端
- javascript - 为什么我在云函数节点 js 中得到减函数错误?
- asp.net - 无法使用 ASP.NET 4.6.1 应用创建 Azure 存储队列消息
- python - 如何在pygame中用小图像填充背景?
- algorithmic-trading - 使用 MQL5 向智能交易系统添加追踪止损
- java - 为什么我在调用 glMultiDrawElementsIndirect 时收到错误 INVALID_OPERATION