我在我的一个应用程序控制器中有这个HttpPost Action,它采用以下参数:
[HttpPost]
IHttpActionResult Send(List<int> channelsIds, List<uint> destinationsIds, string content,
string title, MessagePriority priority)
{
..
}
我知道通常复杂的物体应该通过身体和简单的物体通过uri发送,但我已经读过只能从身体中取出一个参数。如果是这样,处理这个问题的最佳方法是什么?
此外,我应该使用这些方法中的一种来传递参数吗?其中一个更好吗?
编辑: 我可以将所有参数加入到单个SendRequest对象中吗?这将如何运作?
答案 0 :(得分:0)
查看Asp.Net Web Api model binding它会提供您想要了解的更多信息。
在您的情况下,您应该将所有参数包装到单个模型中:
public class SendRequest
{
public List<int> channelsIds {get;set;}
public List<uint> destinationsIds {get;set;}
public string content {get;set;}
public string title {get;set;}
public MessagePriority priority {get;set;}
}