views:

652

answers:

4
+1  Q: 

file upload issue

Hello everyone,

I will need client (end user) through browser to upload big files (e.g. similar to Youtube's scenario which uploads big video files), the file size should be no larger than 500M bytes.

I am using ASP.Net + C# + VSTS + IIS 7.0 as my development platform. Any ideas or good practices about how to handle big file upload issue? Any reference samples or documents are appreciated.

thanks in advance, George

+2  A: 

The answers to this related question recommend SWFUpload or NeatUpload for uploading large files through the browser. NeatUpload is an ASP.NET componant which might well fit with your environment.

There is also JUpload.

Colin Pickard
Thanks Colin, one more question, why using RIA based solution is preferred, because better upload performance or something else?
George2
Browser support for standard HTTP doesn't allow things like specifying which file types are allowed, also stuff like progressbars are better supported by flash/java
Colin Pickard
1. Using FileUpload control can not specify file type? I am confused. 2. I think using non-RIA based solution could also implement progress bar, like how we upload attachment is Gmail. So, it does not mean using plain Http can not implement progress bar. Any comments?
George2
One question about the meaning of "executionTimeout" parameter in IIS 6. Does it mean max time of the whole time of upload process? Or it means max idle time (idle I mean no file chunk is transferred from browser to server, so if continue to transfer file chunks, even if slow, there will no time out)?
George2
+2  A: 

You need to set maxRequestLength to appropriately handle big file and also set executionTimeout so that IIS does not abandon the request, in web.config file

<system.web>
     <httpRuntime executionTimeout="300" maxRequestLength="512000" />
</system.web>

Much more detailes are here in Jon Gallowy's article about uploading big files.

Here is article on MSDN about uploading files in asp.net 2.0

TheVillageIdiot
Thanks TheVillageIdiot, one more question, why using RIA based solution is preferred, because better upload performance or something else?
George2
I think with RIA you can give better feedback for the long running operation to user.
TheVillageIdiot
Thanks, 1. so only user experience benefits? No upload performance or other benefits consideratinos? 2. Why using non-RIA based solution could not have good user experience, could you give me an example please?
George2
One question about the meaning of "executionTimeout" parameter. Does it mean max time of the whole time of upload process? Or it means max idle time (idle I mean no file chunk is transferred from browser to server, so if continue to transfer file chunks, even if slow, there will no time out)?
George2
From one IBM document [http://is.gd/17ZXG]:- The executionTimeout parameter specifies the maximum number of seconds that a request, such as opening a Websheet, is allowed to execute before being automatically shut down by Microsoft Internet Information Services (IIS).
TheVillageIdiot
here is a page for IIS 7 configuration parameters: http://msdn.microsoft.com/en-us/library/aa347568(VS.85).aspx
TheVillageIdiot
1. Looks like no timeout setting for IIS 7.0? 2. For the definition of timeout, I still have a confusion. Suppose I set timeout value to 5 minutes, and I upload a file, which is 10M and upload at rate of 1M/minute, which continues to send upload request to server but takes more than 5 minutes (10 minutes), in this scenario, does it mean timeout or not?
George2
+1  A: 

Nearly all sites that handle very large uploads do so by default using Adobe Flash. Usually they'll fall back to a simple browser upload, but managing things the progress of the current upload is significantly easier to do in flash.

tylerl
I am confused, you suggest we use flash or not?
George2
I think the recommendation is use flash (or java), but allow standard HTTP upload if the user doesn't have flash/java available
Colin Pickard
why using flash (or java) based solution is preferred, because better upload performance or something else?
George2
One question about the meaning of "executionTimeout" parameter in IIS 6. Does it mean max time of the whole time of upload process? Or it means max idle time (idle I mean no file chunk is transferred from browser to server, so if continue to transfer file chunks, even if slow, there will no time out)?
George2
+3  A: 
    <system.web>
        <httpRuntime executionTimeout="300" maxRequestLength="512000" />
    </system.web>

This will not work in IIS7! httpRuntime is for IIS6 and bellow. The correct way to allow large file uploads in IIS7 is:

1) Add the following lines to the web.config file:

[Web.config] maxAllowedContentLength attribute for IIS7

<system.webServer>
   <security >
      <requestFiltering>
          <requestLimits maxAllowedContentLength="1024000000" />
      </requestFiltering>
   </security>
</system.webServer>

2)Then open the file C:\Windows\System32\inetsrv\config\applicationHost.config and find the line:

<section name="requestFiltering" overrideModeDefault="Allow" />

overrideModeDefault should be Allow.

Genady Sergeev
One question about the meaning of "executionTimeout" parameter in IIS 6. Does it mean max time of the whole time of upload process? Or it means max idle time (idle I mean no file chunk is transferred from browser to server, so if continue to transfer file chunks, even if slow, there will no time out)?
George2
Another question is, is there a parameter to specify timeout in IIS 7?
George2
I am almost sure that exectutionTimeout applies to IIS7 as well. In concern with your first question: the timeout specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET. i.e. if your upload is not completed in 110 seconds (by default) ASP will shut down the process.
Genady Sergeev