mvc $.ajax使用属性contentType时500异常

mvc $.ajax使用属性contentType时500异常

mvc $.ajax使用属性contentType时500错误
Js代码
JScript code

            $.ajax({
                type: "POST",
                url: "/Ajax/PhoneNumber",
                data: {
                    number: $("#number").val().substring(0, 7)
                },
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                    alert(msg.message);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert("Status:" + XMLHttpRequest.status + " readyState:" + XMLHttpRequest.readyState + " textStatus:" + textStatus);
                }
            });



Controller代码
C# code

        [HttpPost]
        public JsonResult PhoneNumber(string number)
        {
            string value = BLL.PhoneNumberInfo.Get(number);
            return Json(new { message = value }, JsonRequestBehavior.AllowGet);
            //return Content(value);            
        }




当加入contentType: "application/json; charset=utf-8"时,就会返回500错误
使用默认"application/x-www-form-urlencoded"时就会正常返回json

请问这是什么原因呢?


------解决方案--------------------
500错误是服务器端错误。看你服务器端程序有什么问题了。
------解决方案--------------------
500 好像是返回的字符串有html吧?
------解决方案--------------------
探讨

500 是服务器内部错误,
因该是服务器端程序出现了问题,
排查下服务器端代码
可以使用try catch 将异常内容返回到客户端