angularjs ajax post 对象失败 Json 出现 MVC 5 500 错误

angularjs ajax post fails Json objects with MVC 5 500 Error

我有一个与我的 angularjs 绑定的更新按钮。

我一直收到 500 错误。

当我单击按钮时,我看到我正在 posting ID 1 和今天的“4”,但由于某种原因,我的 MVC 尽管我有一个有效的控制器但没有被触发。以下是我试过的一些控制器。

javascript 和 angular ..

 <button class="btn btn-danger" ng-click="update()"> Update </button>

 function MainCtrl($scope, $http) {
 $scope.update = function() {
                $.ajax({
                    url: "Home/EditResult",
                    data: {
                        ID: angular.toJson($scope.today.ID),
                        today: angular.toJson($scope.day)
                    },
                    type: "post",
                    contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                    success: function (data) {
                    }
                });
            }

我的控制器

public JsonResult EditResult(int ID, string today)
    {
        ViewBag.Message = "Your contact page.";

        return Json("string");
    }




    public JsonResult EditResult(string ID, string today)
    {
        ViewBag.Message = "Your contact page.";

        return Json("string");
    }


    public JsonResult EditResult(JsonResult data)
    {
        ViewBag.Message = "Your contact page.";

        return Json("string");
    }

我也试过完整的 post,但也失败了

$scope.update = function() {
            $http({
                method: "POST",
                url: 'Home/EditResult',
                data: {ID: $scope.today.ID, today: $scope.day},
                headers: {'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'}

            }).success(function() {
                alert(data);
            });
        };

不明确的控制器...更改了其他控制器的名称并且只使用了一个并且能够 post 与上述任何一个 ajax 或完整 post.