gpt4 book ai didi

c# - 发布请求正文太大(参数对象中的字符串太大)

转载 作者:行者123 更新时间:2023-11-30 12:12:06 24 4
gpt4 key购买 nike

我有一个 MVC 方法:

public void PushFile([FromBody]FileTransport fileData)

类是:

public class FileTransport
{
public string fileData;
}

在 fileData 中,我将文件中的 byte[] 转换为 string (UTF-8),因此字符串可以很大。

问题是:如果字符串太大大(超过 15000 个字符),fileData 参数为 null。如果字符串不是那么大,则一切正常,参数也应如此。

如何让 MVC 接受更大的字符串,或者我是否需要事先以某种方式压缩字符串?编辑:已经尝试过:

<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483644"/>
</webServices>
</scripting>
</system.web.extensions>

但是不起作用。也许是因为 MVC 使用 JSON.NET 而不是普通的 JsonSerializer?

最佳答案

您是否尝试增加请求的最大长度?

<system.web>
<httpRuntime maxRequestLength="{REQUEST_LENGTH}"/>
<system.web>

关于c# - 发布请求正文太大(参数对象中的字符串太大),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14176351/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com