1. <tfoot id='jgK4y'></tfoot>
    • <bdo id='jgK4y'></bdo><ul id='jgK4y'></ul>
  2. <i id='jgK4y'><tr id='jgK4y'><dt id='jgK4y'><q id='jgK4y'><span id='jgK4y'><b id='jgK4y'><form id='jgK4y'><ins id='jgK4y'></ins><ul id='jgK4y'></ul><sub id='jgK4y'></sub></form><legend id='jgK4y'></legend><bdo id='jgK4y'><pre id='jgK4y'><center id='jgK4y'></center></pre></bdo></b><th id='jgK4y'></th></span></q></dt></tr></i><div id='jgK4y'><tfoot id='jgK4y'></tfoot><dl id='jgK4y'><fieldset id='jgK4y'></fieldset></dl></div>

    <small id='jgK4y'></small><noframes id='jgK4y'>

    <legend id='jgK4y'><style id='jgK4y'><dir id='jgK4y'><q id='jgK4y'></q></dir></style></legend>

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

      时间:2023-07-11

        <tbody id='VJYGq'></tbody>
      • <tfoot id='VJYGq'></tfoot>

          <i id='VJYGq'><tr id='VJYGq'><dt id='VJYGq'><q id='VJYGq'><span id='VJYGq'><b id='VJYGq'><form id='VJYGq'><ins id='VJYGq'></ins><ul id='VJYGq'></ul><sub id='VJYGq'></sub></form><legend id='VJYGq'></legend><bdo id='VJYGq'><pre id='VJYGq'><center id='VJYGq'></center></pre></bdo></b><th id='VJYGq'></th></span></q></dt></tr></i><div id='VJYGq'><tfoot id='VJYGq'></tfoot><dl id='VJYGq'><fieldset id='VJYGq'></fieldset></dl></div>
          <legend id='VJYGq'><style id='VJYGq'><dir id='VJYGq'><q id='VJYGq'></q></dir></style></legend>

          <small id='VJYGq'></small><noframes id='VJYGq'>

              <bdo id='VJYGq'></bdo><ul id='VJYGq'></ul>

              • 本文介绍了ASP.NET Core 3.0 [FromBody] 字符串内容返回“无法将 JSON 值转换为 System.String."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

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

                Using [FromBody] string content on an ApiController in ASP.NET Core 3.0 returns a validation error:

                {"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."]}}
                

                当客户端使用 content-type 发布数据时:application/json

                when the client post data with content-type : application/json

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

                How do I get the raw json data as a string in my api controller in .NET Core 3.0? Without the client having to update its content type?

                推荐答案

                不确定这是否有帮助,但我认为他们在 .net core 3.0 Newtonsoft.JSON 包中进行了一些更改,因此您可以尝试一下

                Not sure this help but I think they made some change in .net core 3.0 Newtonsoft.JSON package so you can try this

                安装 Microsoft.AspNetCore.Mvc.NewtonsoftJson 包.

                在你的 startup.cs 添加

                In your startup.cs add

                services.AddControllers().AddNewtonsoftJson();

                这篇关于ASP.NET Core 3.0 [FromBody] 字符串内容返回“无法将 JSON 值转换为 System.String."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:与 Request.RequestURI 等效的 ASP.NET Core MVC 是什么? 下一篇:ASP.NET Core MVC 混合路由/FromBody 模型绑定&amp;验证

                相关文章

                • <bdo id='moary'></bdo><ul id='moary'></ul>
                <tfoot id='moary'></tfoot>

                <legend id='moary'><style id='moary'><dir id='moary'><q id='moary'></q></dir></style></legend>

                    <small id='moary'></small><noframes id='moary'>

                  1. <i id='moary'><tr id='moary'><dt id='moary'><q id='moary'><span id='moary'><b id='moary'><form id='moary'><ins id='moary'></ins><ul id='moary'></ul><sub id='moary'></sub></form><legend id='moary'></legend><bdo id='moary'><pre id='moary'><center id='moary'></center></pre></bdo></b><th id='moary'></th></span></q></dt></tr></i><div id='moary'><tfoot id='moary'></tfoot><dl id='moary'><fieldset id='moary'></fieldset></dl></div>