// Server-side Model to bind
public class CurrentPipelineRequest
{
public List<string> Usernames { get; set; }
}
// Controller
[HttpPost]
public HttpResponseMessage CurrentPipelineByMilestone(CurrentPipelineRequest currentPipelineRequest)
{
//.....
}
// Jquery/Ajax
var model = {
'Usernames' : JSON.stringify(["me", "you", "I"])
};
$.ajax({
contentType: 'application/json',
type: 'POST',
url: 'api/Dashboard/CurrentPipelineByMilestone'
data: model,
success: function (data) {
alert('success');
}
});
當前,控制器操作參數「currentPipelineRequest」將爲空。Web API - 具有收集屬性的簡單Post模型不具有約束力
我發誓我在之前的嘗試中嘗試過,哦,謝謝,現在正在工作:) – contactmatt