即使操作没有错误,asp.net核心也会抛出500

时间:2019-03-07 21:28:13

标签: asp.net-mvc asp.net-core

我不确定在asp.net core 2.2动作将HTTP 500返回到浏览器的情况下如何解决问题,即使有一个匹配的视图它应该返回并且即使该动作完全完成也是如此。返回View()语句。

这是浏览器中的代码,尽管返回了视图,但我从操作中得到的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
}

我想返回在VIews下Analysis文件夹中的WhyDoesTHisFail视图。

0 个答案:

没有答案