【问题标题】:Angular Js Post Operation '500 (Internal Server Error)' Error?Angular Js 后操作“500(内部服务器错误)”错误?
【发布时间】:2016-05-10 05:27:41
【问题描述】:
createEmpModule.controller('createEmpCtrl', function ($scope, $http) {
$scope.listDatas = function () {
    $http.post("/Common/Common/GetLanguages").then(function (result) {
        $scope.list = result;
    });
}
$scope.listDatas();
});

angular.min.js:9827 POST http: //localhost:xxxxx/Common/Common/GetLanguages 500 (Internal Server Error) 

角度误差线:

xhr.send(post || null);

所以,函数返回值,

【问题讨论】:

  • 更像是服务器端的问题。
  • 至少搜索一下 500 错误是什么意思!
  • 我已经探索过了。说你知道。
  • 如果你已经探索过了,那么你应该知道你需要调试你的服务器代码

标签: angularjs asp.net-mvc


【解决方案1】:

首先让我感到震惊的是,您正在制作$http.post() 而不发送任何数据。

$scope.listDatas = function () {
    $http.post("/Common/Common/GetLanguages", [dataObjectGoesHere]).then(function (result) {
        $scope.list = result;
    });
}

我的猜测是你想要 .get() 代替。

$scope.listDatas = function () {
    $http.get("/Common/Common/GetLanguages").then(function (result) {
        $scope.list = result;
    });
}

我要说的第二件事是检查您的服务器错误日志!他们将掌握导致您的 500 错误的关键。我愿意打赌 1.00 美元,您在尝试在没有数据的情况下将 POST 发送到期望 GET 请求的位置时遇到错误。

【讨论】:

    【解决方案2】:

    我找到了一个错误解决方案。 它不是来自控制对象的对象类型。 我创建了一个新模型并解决了。

    “/”应用程序中的服务器错误。

    ? ? 类型 'System.Collections.Generic.Dictionary`2[[System.SByte, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral , PublicKeyToken=b77a5c561934e089]]' 不支持字典的序列化/反序列化,键必须是字符串或对象。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多