I have the following javascript class which I am trying to pass to an ASP.NET MVC Controller
var postParams = {
attributes : [
{
name : '',
description: '',
attributeType : '',
value : ''
}
]
};
postParams.attributes[0] = new Object();
postParams.attributes[0].name = "test";
postParams.attributes[0].description = "test";
postParams.attributes[0].attributeType = "test";
postParams.attributes[0].value = "test";
Here's how I call the Controller method:
var actionURL = "@Url.Action("Save", "Catalog")";
$.ajax({
type: "POST",
url: actionURL,
data: postParams ......
On the Controller side I've declared a ViewModel as follows:
public class AttributeViewModel
{
public string name { get; set; }
public string description { get; set; }
public string attributeType { get; set; }
public string value { get; set; }
}
My Controller Save method is declared as follows:
public JsonResult Save(AttributeViewModel[] attributes)
When I execute the value of attributes is always null.
Any ideas? Not sure how to even start debugging this.