Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angularjs $http.post, asp.net mvc controller gets null

In my Angularjs service I have this code:

$http.post("/EditWorkout/GetId", data).error(function (responseData) {
            console.log("Error !" + responseData);
        });

And I have this method in my ASP.net controller:

       [System.Web.Http.HttpPost]
        public JsonResult GetId(string routineId)
        {
            try
            {
                string x = routineId;
                return Json(new {success = true});
            }
            catch (Exception ex)
            {

                return Json(new { success = false, errorMessage = ex.Message });
            }

        }

I've put a break point on return Json(new {success = true}); and it gets fired, but my routineId is for some reason null, and data which I send using angular's $http.post isn't.

Why is this happening ?

like image 621
hyperN Avatar asked Oct 08 '13 09:10

hyperN


1 Answers

try this:

$http.post("/EditWorkout/GetId", { routineId : data}).error(function (responseData) {
            console.log("Error !" + responseData);
        });
like image 114
Marian Ban Avatar answered Nov 15 '22 19:11

Marian Ban