I am using angularjs and ionic.I post multiple data from angular js to Api Controller in asp.net mvc
I have below code in order to post multiple form data to controller in asp.net mvc from angularjs.
  $http({
        method: 'POST',
        url: 'http://localhost:51425/api/values/Response',
        params: { PropertyFirst: "1", PropertySecond: "2" },
        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
    }).success(function (data) {
        alert("ok");
    });
If i use below code this works
[HttpPost]
public object Response(string PropertyFirst , string PropertySecond)
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
return null;
}
However, if i use below code it is not working
PropertyClass
public string PropertyFirst{ get; set; }
public string PropertySecond{ get; set; }
Controller side
[HttpPost]
public object Response(PropertyClass propertyValues)
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");
return null;
}
I get below error :
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
Question:
How can i post PropertyFirst and PropertySecond to PropertyClass ?
Any help will be appreciated.
Thanks.