Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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 ?

share|improve this question
    
What's inside the data variable? And what's the Content-Type request header being sent? Look at the development console of your Google Chrome browser to see the exact request being made. –  Darin Dimitrov Oct 8 '13 at 9:07
    
Yes, it is a variable, I've even tried using "sometext" instead of data, and Content-Type is application/json;charset=utf-8 –  hyperN Oct 8 '13 at 9:12
    
And Status Code is HTTP/1.1 200 OK –  hyperN Oct 8 '13 at 9:15

1 Answer 1

up vote 1 down vote accepted

try this:

$http.post("/EditWorkout/GetId", { routineId : data}).error(function (responseData) {
            console.log("Error !" + responseData);
        });
share|improve this answer
    
That solved my problem, tnx :) –  hyperN Oct 8 '13 at 10:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.