Response.write is asynchronous?

B

Buddy Ackerman

I am creating a ZIP file on the fly and streaming it out to the client using Response.WriteFile(FileName, StartPos,
FileSize). Because this ZIP contains files that are on my server and I don't really want a bunch of duplcate data
filling up my server I need to delete the ZIP file after it's streamed to the client. So I do something like this:

Response.WriteFile(FileName, StartPos, FileSize)
File.Delete(filelocation & FileName)

Well this doesn't work very well because apparently the response is still being written when the delete command is
issued. Buffering is not on and I don't really want it on because I don't think there is enough server RAM to ever
handle the amount buffering that this would require (these zip files can be very large, like 50 MB just for one user).
So, what's a developer to do?



--Buddy
 
S

Shawn B.

Write it to the file system instead and provide them with a link, or a
redirect to the link to it'll automatically start downloading. Then, delete
the file. If something goes wrong and the operation can't be completed,
either provide a way so the system will re-use the same file for the user,
or after a certain amount of time it'll automatically be purged.


Thanks,
Shawn


Buddy Ackerman said:
I am creating a ZIP file on the fly and streaming it out to the client
using Response.WriteFile(FileName, StartPos,
FileSize). Because this ZIP contains files that are on my server and I
don't really want a bunch of duplcate data
filling up my server I need to delete the ZIP file after it's streamed to
the client. So I do something like this:
Response.WriteFile(FileName, StartPos, FileSize)
File.Delete(filelocation & FileName)

Well this doesn't work very well because apparently the response is still
being written when the delete command is
issued. Buffering is not on and I don't really want it on because I don't
think there is enough server RAM to ever
handle the amount buffering that this would require (these zip files can
be very large, like 50 MB just for one user).
 
B

Buddy Ackerman

I am writing the file to the disk. The response.writefile apparently releases and allows the next statement to execute
before the write is complete. Probably does this so as to not tie up the script longer than the script timeout setting.

Guess I'll have to setup a separate process tah cleans up the directory where these files are stored.

--Buddy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top