forum

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

How to Passing IEnumerable parameter to ASP.NET MVC web API action?

Anonymous User577403-Sep-2013

I have two models:

Transaction:

public class Transaction
{
public string Part { get; set; }
public string Description { get; set; }
publicIEnumerable<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.


Updated on 03-Sep-2013
I am a content writter !

Can you answer this question?


Answer

0 Answers

Liked By