Adding a record using angularJS in c# getting this error " POST : 500 internal server Error".
Tried to change the Method from POST to GET at that time the error dint occured but also the record was not inserted. there is no use of strDueDate as of now
<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>
this is my aspx.cs code :
[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();
}
}
this is my cs code :
public DataSet AddAction(String strAction, int intCategory, int
intAssignedTo)
{
DbCommand objdbCommand = db.GetStoredProcCommand("AddAction");
db.AddInParameter(objdbCommand, "@strAction", DbType.String, strAction);
db.AddInParameter(objdbCommand, "@intCategory", DbType.Int32,intCategory);
db.AddInParameter(objdbCommand, "@intAssignedTo", DbType.Int32, intAssignedTo);
DataSet ds = db.ExecuteDataSet(objdbCommand);
return ds;
}