.NET Core名称中带有“ Id”的可空int属性上的无效ModelState

时间:2018-11-28 11:05:12

标签: c# asp.net-core .net-core

我通过从表单获取数据来进行PUT / POST查询。我的意思是:

public async Task<IActionResult> Post([FromForm] Model model) { ... }

在这个Model中,我拥有财产int? FromId

当我尝试验证ModelState时,出现以下错误:

  

“值'null'对于FromId无效。”

我在此属性上没有任何属性。

如果我将属性FromId更改为From,那么它将正常工作。

这是什么原因?而我该如何解决呢?

0 个答案:

没有答案