如何解决C# ReadAsAsync - 系统内存不足问题
我有一个 WEB API,它返回一些数据,其中包括大字节数组 [文件大小为 400 MB] 现在我收到了来自 API 的响应,但是在将它放入我的课堂时,我收到了一个错误 -
Exception of type 'System.OutOfMemoryException' was thrown at newtonsoft.json.JsonTextReader.PreparebufferForReadData
调用 API 时 -
HttpResponseMessage response = httpClient.GetAsync($"api/getdoc/{Id}").Result;
这里我得到了有效的响应,但它在 ReadAsAsync 中崩溃了
if (response.IsSuccessStatusCode)
{
responseCollection = response.Content.ReadAsAsync<IList<DocServiceResponse>>().Result;
}
我的 DocServiceResponse 类 -
public sealed class DocServiceResponse
{
#region Constructors
public DocServiceResponse()
{
}
#endregion
#region Properties
public Guid Code { get; set; }
public byte[] File_Stream { get; set; }
#endregion
}
似乎在反序列化字节数组时失败了。有办法吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。