System.OutOfMemoryException on file download

Posted by frosty on Stack Overflow See other posts from Stack Overflow or by frosty
Published on 2010-04-08T12:26:30Z Indexed on 2010/04/08 12:43 UTC
Read the original article Hit count: 534

Filed under:
|

I have an ashx handler with the following code. The idea is to hide the path of the file and prompt a download

       context.Response.Clear();
       context.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
       context.Response.AddHeader("Content-Length", file.Length.ToString());
       context.Response.ContentType = "application/octet-stream";
       context.Response.WriteFile(file.FullName);

This works fine for some files however on others i get

Exception of type 'System.OutOfMemoryException' was thrown.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about memory-management