Click here to Skip to main content
14,732,983 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using httppost action in controller and calling using angular js. but getiing second parameter always null.

My action method
[HttpPost]
public JsonResult Services_PageSize(string PageSize, string ServiceCategory_Id)
{
    int n;
    bool isNumericPageSize = int.TryParse(PageSize, out n);
    bool isNumericServiceCategory_Id = int.TryParse(ServiceCategory_Id, out n);
return new JsonResult { Data = new { Services = _Services, Status =        isNumericPageSize }, };
}


and my angular js controller is
 this.getServices = function (pageSize, ServiceCategoryId) {
   return $http({
    method: "post",
    url: "/Home/Services_PageSize?pageSize=" + pageSize + "& ServiceCategoryId=" + ServiceCategoryId

});
Posted
Comments
Afzaal Ahmad Zeeshan 9-Jul-15 16:10pm
   
How do you initiate the request (function)?

1 solution

You can try this,

this.getServices = function(pageSize, ServiceCategoryId) {
    var d = {
        PageSize: pageSize,
        ServiceCategory_Id: ServiceCategoryId
    };
    return $http({
        method: "post",
        url: "/Home/Services_PageSize",
        data: d
    });
}


Your variable name is not matching with the variable of the server method, I hope it helps.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900