HOW TO PASSING IENUMERABLE PARAMETER TO ASP.NET MVC WEB API ACTION?

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
 4513  View(s)
Ratings:
Rate this:

I have two models:

Transaction:

public class Transaction
{
public string Part { get; set; }
public string Description { get; set; }
public IEnumerable<LotNum> LotsList { get; set; }
}

LotNum:

public class LotNum
{
public string LOTNUM { get; set; }
public string LOTQTY { get; set; }
} 

Controller Action: 

[HttpPost]
public HttpResponseMessage ProcessTransaction(Transaction model)
{      

}

When I am passing parameter to this action via Ajax call, the LotsList property values will always be blank:

var me = this,

    values = me.getValues();
values.Part = 'R001';
values.Description = 'Sample Desc';
values.LotsList = [{
            "LOTNUM": "L7",
            "LOTQTY": "5"
        },
        {
            "LOTNUM": "L8",

     "LOTQTY": "5"

}];

Ext.Ajax.request({
dataType: 'JSONP',
        url: '/Base/ProcessTransaction',
        params: values,
method: 'POST',
success: function (response) {
},
failure: function (response) {             
}

});

Please let me know what I am missing and how can I get my problem resolved?
Thanks.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!