Form' threw an exception of type 'System.InvalidOperationException'

环境:VS2017 NetCore 2.2 Razor Layui 

在处理异步请求是遇到"((Microsoft.AspNetCore.Http.Internal.DefaultHttpRequest)this.Request).Form' threw an exception of type 'System.InvalidOperationException' 

Microsoft.AspNetCore.Http.IFormCollection {System.InvalidOperationException}"

后端代码:

前端代码:

 

问题发生的原因不请.

 在具体使用中发现 前端提交的json最好是放到json解析器中验证一下是否正确,若json不正确这是 FromBody 的数据也会为null.

在这里先记录下来.

原文地址:https://www.cnblogs.com/softwaretailor/p/11561449.html