Jquery Ajax调用未命中控制器操作方法,状态500,内部服务器错误

Jquery Ajax调用未命中控制器操作方法,状态500,内部服务器错误,jquery,ajax,asp.net-mvc,xmlhttprequest,responsetext,Jquery,Ajax,Asp.net Mvc,Xmlhttprequest,Responsetext,我的ajax对控制器的调用操作方法没有命中控制器,而是在两者之间中断。它表示xhr.status=500,response text=Internal Server Error 同样的代码在其他项目中运行良好 JavaScript代码 ajaxCall: function (data, url, success, error, noShow) { // make sure that there is never an empty POST body to protect against

我的ajax对控制器的调用操作方法没有命中控制器,而是在两者之间中断。它表示
xhr.status=500
response text=Internal Server Error

同样的代码在其他项目中运行良好

JavaScript代码

 ajaxCall: function (data, url, success, error, noShow) {
    // make sure that there is never an empty POST body to protect against proxy allowing too soon
    if (!data) {
        data = "{'dummy':1}";
    }
    var reqData = data;
    $.ajax({
        type: "POST",
        traditional: true,
        url: url,
        data: data,
        // switch on/off geenraic AJAX events bound globally
        /** @default false
        */
        global: !(noShow || false),
        cache: false,
        dataType: "json",
        // add CSRF token to each request
        beforeSend: function (xhr) { /* jquery 1.5.* use headers */
            var csrf_token = $("[name=__RequestVerificationToken]").val();
            xhr.setRequestHeader('__RequestVerificationToken', csrf_token);
        },
        contentType: "application/json",
        success: function (data) {
            success(data);
        },
        error: function (a, b, c) {
            // repeat ajax call when "Empty body element" message gets returned. It means that proxy challenge was completed too soon.
            if (a.responseText == "EmptyBodyElement")
                Service.ajaxCall(reqData, url, success, error);
            else {
                if (error)
                    error(a, b, c);
                else
                    Service.responseError(a, b, c);
            }
        }
    });
},
我在jQuery1.9.1中收到错误

if ( callback && ( isAbort || xhr.readyState === 4 ) ) 
xhr.status=500
xhr.responsetext=内部服务器错误


同样的代码在其他项目中工作,我检查了所有的regrences是否到位。

控制器操作方法

[异名]

public ActionResult CheckUserStatus(字符串UserId,bool NewUserStatusCheck)

{

}

断点未命中


Xhr.responseText=“内部服务器错误”

我遇到了类似的问题

这是我的错误代码。

JQUERY代码

 $.ajax({
         url: "@Url.Action("AllocateByCapacity","BookScenario")",
         dataType: 'json',
         type: 'POST',
         contentType: 'application/json',
         data: JSON.stringify({'scenarioId':JSON.stringify(PlanningBookHandler.getScenarioId())                                     
                        }),
                        success: function (response) {
                            SCP.Utils.showMessageDialog("Records Updated");
                        },
                        error: function () {
                            SCP.Utils.showMessageDialog("Records UpdateFailed");
                        }
                    });


控制器动作方法代码

 public ActionResult AllocateByCapacity(int scenarioId)
 {

            return Json(new object());
 }

在我的例子中,您可以看到我正在将字符串值传递给action方法,该方法需要一个整数参数。这就是我在代码中发现的错误。将参数更改为整数值代码后,效果良好。

任何人请帮助。。通过在不同线程上对此问题进行研究,我了解到问题在.config中的某个地方。。有人建议在Fiddler中检查请求和响应,但请求未到达服务器,响应为nothing。。