首页 新闻 会员 周边 捐助

Minimal API 报错:"Body was inferred but the method does not allow inferred body parameters"

0
悬赏园豆:30 [已解决问题] 解决于 2025-10-05 22:37

ASP.NET Core Minimal API 项目在启动时出现下面的错误:

System.InvalidOperationException: Body was inferred but the method does not allow inferred body parameters.
Below is the list of parameters that we found: 

Parameter           | Source                        
---------------------------------------------------------------------------------
BrandId             | Route (Inferred)
ReleasedOnly        | Query String (Inferred)
TopicIds            | Body (Inferred)
TagId               | Query String (Inferred)
OrderByString       | Query String (Inferred)
query               | As Parameter (Attribute)


Did you mean to register the "Body (Inferred)" parameter(s) as a Service or apply the [FromServices] or [FromBody] attribute?
dudu的主页 dudu | 高人七级 | 园豆:24827
提问于:2025-10-05 22:03
< >
分享
最佳答案
0

把 TopicIds 参数类型从 List<int> 改为 int[] 解决了

dudu | 高人七级 |园豆:24827 | 2025-10-05 22:37
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册