Click here to Skip to main content
15,668,126 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
I have images on my website where the user can download selected images. When the user selects more than one image the files are downloaded as zip files; the zipping process takes place on the server.

However, when the user selects more files( the size also increase let say by 50MB) so when he presses download the zipping starts on server. The web page is hanging and the user can't do anything until the zipping process has completed.

Sometimes the browser (like Chrome) gives messages (process is taking too long , kill this process). So I am looking for some help here.

I need a solid suggestion :)

Updated 20-Jan-11 0:11am

This[^] will give you an idea.

Btw if you posted your code, our experts can glance it, and give the feedback.
Share this answer
bachasafyan 20-Jan-11 6:16am    
Thanks for the link,
I have the same code
The problem is that, the problem is with zipping the files on the server due to there large size.
So I am looking for:
is there any way that i can start this zipping on the server as a different process and user continue his work, (not waiting for the zipping)
soni uma 20-Jan-11 6:18am    
Create one exe that make zipping process and send mail to client with file.

You can increase httpruntime using web confige.
In web confige use this ..
<httpRuntime executionTimeout="90" maxRequestLength="2097151" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100"/>

Or another thing is you can use your own exe that do this all thing in background. when file size is more than 50mb than tell user that an automatic mail will send you will file. you have to start your exe on server that do all zipping process and send mail to user.
Share this answer
bachasafyan 20-Jan-11 6:30am    
@ Soni Uma,
I use the time out what you mentioned but that didnt helped me,
the browser still hangs as the zipping take file and the chrome gives the message Kill the process ,
and mailing to user is like the customer cant wait for the email.
he want to do it in real time :(

do you have idea how can i tell the server to start zipping as another process and the user continue the browsing?
soni uma 20-Jan-11 6:57am    

I think as per your requirement you can not do that after start zipping and customer continue browsing. Because how can u give customer your zipping file after finished. You have to do following thing that is work for you
1. You have to set limit for your file (No of images)
2. For small file do it using browser but if file going to large than tell customer that file in processing wait for some time and mail that file. (in this case crone is working)
bachasafyan 20-Jan-11 7:20am    
@soni Uma:
Thanks for your useful suggestion.
I will go for Suggestion 2.
Can you refer me to an article or example. for suggestion no2?
thanks for your efforts :)
soni uma 20-Jan-11 7:26am    
See following link it may help you.
bachasafyan 20-Jan-11 7:36am    
@Soni Umi,
Thanks for the link i will look at it and try to follow it, I hope it will be useful :)
Using 7Zip command line tool you can Zip file or folders in server.
you can download 7Zip command line tool from Here[^]

check the sample code to zip a folder

protected void ZipFolder_Click()
       ProcessStartInfo p = new ProcessStartInfo();
       string sourceName = Server.MapPath("test");
       string targetName = Guid.NewGuid().ToString();
       p.FileName = Server.MapPath("7za.exe");
       string ZipCommand = string.Format(@" a -tzip {0}.zip {1}\*", targetName, sourceName);
       p.Arguments = ZipCommand;
       p.WindowStyle = ProcessWindowStyle.Hidden;
       p.UseShellExecute = false;
       Process x = Process.Start(p);
       String errmsg = "";
       while (!x.StandardOutput.EndOfStream)
           errmsg += x.StandardOutput.ReadLine() + "<br />" + Environment.NewLine;

if you want to know more check
7-Zip Command-Line Examples[^]
.NET 7-Zip Executable Tutorial[^]
Share this answer
bachasafyan 20-Jan-11 9:25am    
Thanks for your code and suggestion, I will apply this and will see if it helps me.
Thanks :)
raju melveetilpurayil 20-Jan-11 9:28am    
then why you down voted?
bachasafyan 24-Jan-11 4:14am    
@ raju.M
I am sorry i didnt notice that down voting i am sorry
well i try that code and it didnt worked for me.
The problem still is there.
the page is hanged until the server complete the zipping of the file :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900