C# 更好地理解Http请求参数

C# 更好地理解Http请求参数,c#,rest,asp.net-web-api,C#,Rest,Asp.net Web Api,我的一个应用程序控制器中有此HttpPost操作,该控制器采用以下参数: [HttpPost] IHttpActionResult Send(List<int> channelsIds, List<uint> destinationsIds, string content, string title, MessagePriority priority) { .. } [HttpPost] IHttpActionRes

我的一个应用程序控制器中有此HttpPost操作,该控制器采用以下参数:

[HttpPost]
IHttpActionResult Send(List<int> channelsIds, List<uint> destinationsIds, string content, 
                       string title, MessagePriority priority)
{
   ..
}
[HttpPost]
IHttpActionResult发送(列表通道ID、列表目的ID、字符串内容、,
字符串标题,MessagePriority(优先级)
{
..
}
我知道通常复杂的对象应该通过body发送,简单的对象应该通过uri发送,但是我已经读到,只有一个参数可以从body中获取。如果是这样,处理这个问题的最佳方法是什么

此外,我是否应该使用这些方法之一来传递参数??其中一个更好吗

编辑: 我可以将所有参数合并到一个SendRequest对象中吗?这将如何工作?

检查一下,它将包含比您想知道的更多的信息

在您的情况下,应将所有参数封装到单个模型中:

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;}
}
公共类SendRequest
{
公共列表channelsIds{get;set;}
公共列表目标ID{get;set;}
公共字符串内容{get;set;}
公共字符串标题{get;set;}
公共消息优先级{get;set;}
}

可能是重复的看看,也许你能帮我弄清楚。当我使用属性[HttpPost]时,所有参数都会自动绑定并从请求主体接收?