Home > DeveloperSection > Forums > How to Passing IEnumerable parameter to ASP.NET MVC web API action?
Ankit Singh

Total Post:341

Points:2389
Posted on    September-03-2013 4:22 AM

 ASP.NET MVC ASP.NET MVC 
Ratings:


 0 Reply(s)
 3675  View(s)
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.



Don't want to miss updates? Please click the below button!

Follow MindStick