Angularjs $ http.post, asp.net mpc 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 put a breakpoint on return Json(new {success = true}); , and it starts, but for some reason my function II is null, and the data that I send using angular $ http.post is not.

Why is this happening?

+6
source share
1 answer

try the following:

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

Source: https://habr.com/ru/post/955472/


All Articles