我想在 Asp .net core Web API POST 方法中传递很长的字符串作为参数?

问题描述 投票:0回答:2

我想在 Asp .net core Web API POST 方法中传递很长的字符串作为参数,但是当我传递它时,它只需要开始几个单词。如何解决这个问题?

我传递的数据:

{
"Stack":"  RtrnAddr            Arg#1             Arg#2             Arg#3             Arg#4               Function or address
  -----------------   ----------------- ----------------- ----------------- -----------------   -------------------------------------------------------------------
  00000000`378265ef0 : 00000000`00000001 00000000`38e97628 00000000`1efb5b50 00000000`00000000 
  00000000`0058000001 : 00000000`38e97628 00000000`1efb5b50 00000000`00000000 000007fe`ed12964e 
  00000000`38e987628 : 00000000`1efb5b50 00000000`00000000 000007fe`ed12964e ffffffff`fffffffe 
  00000000`1efb58b50 : 00000000`00000000 000007fe`ed12964e ffffffff`fffffffe 00000000`0028d830 
  00000000`000000000 : 000007fe`ed12964e ffffffff`fffffffe 00000000`0028d830 00000000`001e0644 
"
}
.net .net-core post asp.net-core-webapi asp.net-apicontroller
2个回答
0
投票

api方法中的参数是否添加了[FromBody]属性?

例如:[FromBody] 字符串值

请参阅以下链接。可能有用。

https://www.codeproject.com/Tips/734080/How-to-Pass-a-Large-String-to-a-Web-API-Method-A-2


0
投票
Data you are passing has no issue. It is working. Try this please.

Create another class like this.

public class StackData
    {
        public string Stack{ get; set; }
}

Then use that class with the parameter in api method as below.

public async Task<IActionResult> Post([FromBody] StackData Stack) 
© www.soinside.com 2019 - 2024. All rights reserved.