首页 > 解决方案 > 如何在调试与 c# 一起使用的 angularJS 时找到错误发生的位置

问题描述

我正在将 angularJS 与 C# 一起使用,并且在 POST 请求上出现错误,但我不知道是什么导致了调试时出现错误

在 chrome 浏览器中调试时进入错误部分,但我不清楚为什么会这样。

var req = {
    method:'POST',
    url:'ActionList.aspx/AddAction',
    data:
    {
        strAction: $scope.mdlAction, intCategory: $scope.mdlCategory, intAsssignedTo: $scope.mdlAssignedTo,
        strDueDate:$scope.dtDueDate
    }
}
$http(req).success(function(data){
    result = angular.fromJson(data.d);
    if (result.status == "success") {
        alert('its working');
    }
}).error(function (data) {
    alert('its an error');
    console.log('error: Could not add the student');
});
 [WebMethod]
 [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
 public static string AddAction(String strAction,int intCategory,int 
 intAssignedTo,String strDueDate)
{
    try
    {
        HttpContext.Current.Response.ContentType = "application/json; 
charset=utf-8";
        ActionList AL = new ActionList();
        dynamic json = new JObject();
        obj.AddAction(strAction, intCategory, intAssignedTo, strDueDate);
        json.status = "success";
        return json.ToString();
    }
    catch
    {
        dynamic d = new JObject();
        d.status = "error";
        return d.ToString();
    }
}

标签: c#angularjs

解决方案


推荐阅读