如何将IEnumerable参数传递给ASP.NET Web API操作?

时间:2013-09-02 15:06:44

标签: asp.net-web-api

我有两种模式:

交易:

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; }
}

控制器操作:

[HttpPost]
public HttpResponseMessage ProcessTransaction(Transaction model)
{

}

当我通过Ajax调用将参数传递给此操作时,LotsList属性值将始终为空白:

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) {

            }
        });

请让我知道我错过了什么,如何解决我的问题? 感谢。

0 个答案:

没有答案