Personal Edition | resolution | control | Upload the piece of rubbish after traversing all the posts about uploading large files in csdn. (:-))
upload large files, there are several ways:
1, Shi HttpWorkerRequest method, too difficult to read:-(
2, use the control of third party aspnetupload want Money!! Forget it, we still like it for free.
3, modify Web.config file, but cannot catch error.
4, the way to upload via FTP. The server needs to provide an FTP service.
, had to choose a third way, who let us too stupid! (Too stupid, no relationship, to eat more fish, I heard that eating fish can be smart point.) )
then carefully study the third way of it!
Modify Webcong File:
<system.web>
<httpruntime maxrequestlength= "40690"
usefullyqualifiedredirecturl= "true"
executiontimeout= "6000"
usefullyqualifiedredirecturl= "false"
minfreethreads= "8"
minlocalrequestfreethreads= "4"
apprequestqueuelimit= "100"
enableversionheader= "true"
/>
</system.web>
which is closely related to the upload is:
maxRequestLength
indicates the maximum file upload size supported by asp.net.
This restriction can be used to prevent denial of service attacks caused by a user passing a large number of files to the server.
the specified size is in kilobytes.
The default value for
is 4096 KB (4 MB).
executiontimeout
indicates the maximum number of seconds allowed to execute a request before it is asp.net automatically closed.
unit for seconds, when uploading large files to set this larger.
if server memory is 512M, you can upload files of size 160M. (haven't tried, csdn the unanimous opinion of the public posts.) )
' www.knowsky.com
Here the Web.config setting is over.
but once the size of the uploaded file exceeds the file size of this setting, the following error occurs:
This page cannot display
the page you want to view is currently unavailable. Your web site may be experiencing technical problems, or you need to adjust your browser settings.
Although cannot solve, that also must catch this mistake! What do we do?
recently ate a few fish, think about it, because this error is caused by the file control foreground error, so in the background want to use Try...catch to capture is not feasible.
then thought of using. NET error capture page mechanism to deal with. Yes, it works.
1, first set web.config
<customerrors mode= "on"/>
2, create a new error.aspx file that is designed to trap errors.
3, add page directives to the front page of the ASPX page where the files are uploaded. Errorpage= "Uploaderror.aspx"
4, add some code in the error.aspx to determine if the error message is a foreground error caused by file.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.