【问题标题】:SharePoint ashx handler file download ProblemSharePoint ashx 处理程序文件下载问题
【发布时间】:2011-07-20 20:09:38
【问题描述】:

我有一个 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);

【问题讨论】:

  • 您是否尝试在接收服务器的 web.Config 中增加最大文件大小?
  • 你好。你是怎么做这个处理程序的?我正在尝试按照这篇文章here 做一项工作,但它根本不起作用。

标签: c# asp.net sharepoint handler binarywriter


【解决方案1】:

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

【讨论】:

  • 抱歉文件来自另一个存储文件的服务器,它们必须存储在内存中。 TransmitFile 要求文件是该服务器上的路径。
猜你喜欢
  • 2011-09-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-27
  • 2012-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多