SharePoint ashx 处理程序文件下载问题

发布于 2024-11-25 08:15:17 字数 691 浏览 4 评论 0原文

我有一个 ashx 处理程序,它获取我们正在使用的文件(在 SharePoint 中),然后检查它是什么类型的文件,然后使用 Response.BinaryWrite 进行写入。它从另一台服务器获取此文件,其中包含我们的所有文件。当我下载一个 3MB 左右的文件时,它工作正常。但是当我下载 30MB 或 40MB 文件时,出现错误。

Exception of type 'System.OutOfMemoryException' was thrown.   at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity) 

我检查了我的应用程序池,我们将虚拟内存设置为 1.5GB,实际内存设置为 1GB。我没有想法,不知道下一步该去哪里,有人有任何想法吗?

    case "PDF":
         context.Response.ContentType = "application/pdf";
         context.Response.AddHeader("content-disposition", "inline; filename=" + asset.A_Name);
    }

    context.Response.BinaryWrite(content);

I have a ashx handler that gets a file we are using, this in SharePoint, and then it checks what kind of file it is and then it writes using Response.BinaryWrite. It get this file from another server, that contains all of our files. When I go to download a file thats like 3MB it works fine. But when I go to download a 30MB or 40MB file I get the error.

Exception of type 'System.OutOfMemoryException' was thrown.   at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity) 

I checked my Application Pool at we have it set at 1.5GB for Virtual and 1GB for actual memory. I am out of ideas and dont know where to go next does anyone have any ideas?

    case "PDF":
         context.Response.ContentType = "application/pdf";
         context.Response.AddHeader("content-disposition", "inline; filename=" + asset.A_Name);
    }

    context.Response.BinaryWrite(content);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

擦肩而过的背影 2024-12-02 08:15:17

您可能想尝试 Response.TransmitFile 方法,该方法不会在服务器内存中缓冲内容。

You may want to try Response.TransmitFile method, which does not buffer the content in server memory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文