【发布时间】:2020-08-22 22:27:12
【问题描述】:
我有一个 api 控制器,它接收来自 body 的参数,例如
public virtual async Task<ActionResult> TestCommAsync([FromBody] CommRequest commRequest)
Comm Request对象如下
public class CommRequest
{
/// <summary>
/// Gets or sets the value that represents the collection of <see cref="CommunicationHistory"/>
/// </summary>
public IEnumerable<commItems> commItemsAll{ get; set; }
}
当我通过邮递员传递 {} 空对象时,我的条件
if(commRequest == null) 不起作用..它通过了,因为它不为空..需要帮助以正确的方式检查是否为空和为空
【问题讨论】:
-
public virtual async为什么virtual用于 API?
标签: c# api asp.net-core web