我想在ASP .NET Core Web API POST方法中传递非常长的字符串作为参数吗?

时间:2019-12-02 04:51:34

标签: .net api post .net-core asp.net-apicontroller

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

我通过的数据:

{ “堆栈”:“ RtrnAddr Arg#1 Arg#2 Arg#3 Arg#4函数或地址   ----------------- ----------------- ---------------- ------------------ ----------------- --------------- -------------------------------------------------- -   00000000 38e97628 00000000 00000001 00000000 00000000 00000000 1efb5b50 00000000 38e97628 00000000 0058000001:00000000 00000000 000007fe 1efb5b50 00000000 38e987628 : 00000000 ed12964e   00000000 00000000 000007fe 1efb5b50 00000000 fffffffe 00000000 ed12964e ffffffff 00000000 000007fe 1efb58b50:00000000 fffffffe 00000000 ed12964e ffffffff 000000000 : 000007fe 0028d830   00000000 fffffffe 00000000 ed12964e ffffffff profile_image does not have a default value 0028d830 00000000`001e0644 ” }

2 个答案:

答案 0 :(得分:0)

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

例如:[FromBody]字符串值

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

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

答案 1 :(得分: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)