0

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);
atrljoe
  • 8,031
  • 11
  • 67
  • 110
  • Did you try upping max file size in web.Config of receiving server? – IrishChieftain Jul 20 '11 at 21:06
  • Hello op. How did you made this handler? I'm trying to make one work, following this article [here](https://blogs.msdn.microsoft.com/kaevans/2010/08/04/deploying-an-asp-net-httphandler-to-sharepoint-2010/) but it does not work at all. – Malavos Feb 19 '16 at 13:06

1 Answers1

0

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

Dalei
  • 16
  • sorry the files are coming from another server that stores the files, this they have to be stored in memory. TransmitFile requires that the file be a path on that server. – atrljoe Jul 20 '11 at 20:43