相关疑难解决方法(0)

ASP.NET Core 3.0 [FromBody]字符串内容返回“无法将JSON值转换为System.String。”

在ASP.NET Core 3.0中使用[FromBody]字符串内容会ApiController返回验证错误:

{"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
 "title":"One or more validation errors occurred.",
 "status":400,
 "traceId":"|9dd96d96-4e64bafba4ba0245.",
 "errors":{"$":["The JSON value could not be converted to System.String. Path: $ | LineNumber: 0 | BytePositionInLine: 1."]}}
Run Code Online (Sandbox Code Playgroud)

当客户端发布具有content-type的数据时: application/json

如何在.NET Core 3.0的api控制器中以字符串形式获取原始json数据?无需客户端更新其内容类型?

c# asp.net-core

1
推荐指数
4
解决办法
1010
查看次数

标签 统计

asp.net-core ×1

c# ×1