WebMethod не запускается при вызове с использованием запроса AngularJS
Даже при использовании [WebMethod] [ScriptMethod (ResponseFormat = ResponseFormat.Json)]]
это дает мне 500 внутренних ошибок сервера в качествеметод не уволен, что я должен сделать, чтобы войти в веб-метод или что я сделал неправильно?
<script type="text/javascript">
var app = angular.module("ActionListApp", []);
app.factory("Actions", function () {
var serviceObj = {};
serviceObj.AddAction = function ($http, $scope, $filter) {
debugger;
var req = {
method: 'POST',
url: 'ActionList.aspx/AddAction',
data: {
strAction: $scope.mdlAction, intCategory: $scope.mdlCategory, intAsssignedTo: $scope.mdlAssignedTo
}
}
$http(req).success(function (data) {
result = angular.fromJson(data.d);
alert('success');
//$scope.EventsList = result.Events;
//$scope.Pages = result.Pages;
}).error(function (data) {
alert('error');
console.log('error: Could not add the student');
});
};
return serviceObj;
});
app.controller("ActionController", function ($http, $scope, $filter,
Actions) {
$scope.ctrAddAction = function () {
debugger;
$scope.dtDueDate =
document.getElementById('dtDueDate').value;
Actions.AddAction($http, $scope, $filter);
};
});
</script>
это мой код aspx.cs:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string AddAction(String strAction, int intCategory, int
intAssignedTo)
{
try
{
HttpContext.Current.Response.ContentType = "application/json; charset=utf-8";
dynamic json = new JObject();
DataSet ds = new DataSet();
ds=obj.AddAction(strAction, intCategory, intAssignedTo);
json.action = (JArray)JToken.FromObject(ds.Tables[0]);
return json.ToString();
}
catch (Exception ex)
{
dynamic d = new JObject();
d.status = "error";
d.errormsg = ex.Message;
d.stack = ex.StackTrace;
return d.ToString();
}
}