开发者

File Upload/Download in ASP.NET

Ok, I'm a real newbie at the ASP stuff... I have two related questions:

What are my options for controls I can dynamically add to my webpart to allow a user to upload large files >100MB to the server?

What are my options for controls to trigger a download of a large file in a web browser with a "Save As" dialog box, so that the server can generate a file and send it to the user?

I've seen examples for FileUpload controls, HttpRequest/HttpResponse controls, FileWebRequest controls... its never clear if the examples are intended for windows apps scraping off websites, or client scripts that are tied to buttons, or serverside code that acts on a p开发者_JAVA百科ostback. I guess I'm looking for the latter... something I could write in the server code to trigger the interaction.

If anyone knows where I can find a clear tutorial, that would also be appriciated.


By default, ASP.Net restricts the file uploaded to the server to be 4 MB. We can increase this setting in Web.Config through the tag. The below configuration setting is configured for all default values.

<httpRuntime
 executionTimeout="110"
 maxRequestLength="4096"
 requestLengthDiskThreshold="80"
 useFullyQualifiedRedirectUrl="false"
 minFreeThreads="8"
 minLocalRequestFreeThreads="4"
 appRequestQueueLimit="5000"
 enableKernelOutputCache="true"
 enableVersionHeader="true"
 requireRootedSaveAsPath="true"
 enable="true"
 shutdownTimeout="90"
 delayNotificationTimeout="5"
 waitChangeNotification="0"
 maxWaitChangeNotification="0"
 enableHeaderChecking="true"
 sendCacheControlHeader="true"
 apartmentThreading="false" />

To increase the default upload size, we need to increase the value of maxRequestLength property to whatever we want in KB. Default is 4096 KB(4MB).

To upload 100 MB, set maxRequestLength="102400"

Copy the above configuration inside tag in Web.Config.

this is the link http://programming.top54u.com/post/ASP-Net-FileUpload-Size-Limit-Example.aspx


ASP.NET does have a FileUpload control. For files of that size however, I recommend that you look at an alternative solution, like FTP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜