通过HTTPS连接时,Ajax.BeginForm OnFailure返回空结果

时间:2018-12-08 20:41:08

标签: model-view-controller ajax.beginform

通过非安全协议(http)连接时,我的MVC 5 Web应用程序正确返回错误消息。但是当我通过https连接时,错误消息为空白。思想?注意:我也尝试json return。谢谢!

浏览器调试器输出

HTTP

enter image description here

HTTPS

enter image description here

MVC Controller:
string message = string.Join(" ", errors);
Response.StatusCode = (int)HttpStatusCode.RequestedRangeNotSatisfiable;
return new HttpStatusCodeResult(Response.StatusCode, string.Join(" ", message));

Script:
function ajaxOnFailure(response, status, error) {
debugger;
if (response.status == 500) {
    error = "An internal error has occurred. Please try again. If the problem persists, please contact IT."
}
toastr.error("", error);

}

1 个答案:

答案 0 :(得分:0)

我最终使用了一种解决方法。我没有返回失败响应,而是返回OK响应并通过jquery确定消息的类型。如果失败响应通过https返回消息,那就太好了。

enter image description here

enter image description here