Lost in .NET Code

Developing software in .NET, Security and other ramblings.

"Response Buffer Limit Exceeded" ASP Solution to having to sending a large file

Thursday, April 12, 2007

So lately I have been working in old skool ASP. I hit the problem of sending a large exe file to a client the file size was 30 Meg. A couple of searches all turned to this page.

http://www.fogcreek.com/FogBugz/KB/errors/ResponseBufferLimitExceed.html

So I phoned my hosting company.. who promptly said no to my request to change the AspBufferingLimit . Not suprising this is the limit that stops a infinite loop from consuming the server.

So a few more google pages later and bit of hacking I have hopefully a working solution togther.

Hopefully this might be useful for someone in the future.



Response.AddHeader "Content-Disposition", "attachment; filename=mylargedownload.exe"
Response.AddHeader "Content-Transfer-Encoding","binary"
Response.ContentType = "application/octet-stream"
Const adTypeBinary = 1
Dim strFilePath
strFilePath = Server.Mappath("/download/mylargedownload.exe")
'This is the path to the file on disk.
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
'1 MB
clChunkSize = 1048576
Dim i
For i = 0 To objStream.Size \ clChunkSize
Response.BinaryWrite objStream.Read(clChunkSize)
Response.Flush
Next
objStream.close
Set objStream = Nothing

Labels:

0 Comments:

Post a Comment

<< Home


Subscribe in a reader


Blogs I read

Tristan Phillips
Sarah Blow (.Net Mobile)
Mike Taulty (MS DPE)
Ian Griffths (WPF)
Jack Greenfield


Useful Links

Fircroft Trust Ltd
Unwind Software Ltd


Archives

December 2006   January 2007   February 2007   March 2007   April 2007   May 2007   June 2007   October 2007   November 2007   February 2008   April 2008   May 2008   June 2008   July 2008   August 2008  


Fun and Games



 

This page is powered by Blogger. Isn't yours?