Where the size of the uploaded file is controlled in web. config:
Copy codeThe Code is as follows:
<System. web>
MaxRequestLength is the maximum size of the parameter request to control the upload size (in kilobytes ). The default size is 4096 KB (4 MB ). ExecutionTimeout indicates the maximum number of seconds that can be executed before the request is automatically disabled by ASP. NET. The default value is 90 seconds. The Unit is seconds. For details, refer to Msdn.
Http://msdn.microsoft.com/zh-cn/library/system.web.configuration.httpruntimesection.maxrequestlength%28v=VS.80%29.aspx
Solve the size limit of asp.net uploaded files
For asp.net, only 2 MB files can be uploaded by default. The following configuration is added. You can customize the maximum file size.
<Httpruntime executimaxrequestlength = "40960" usefullyqualifiedredirecturl = "false"/>
If not, you can use the solution provided by Si Gui:
We encountered one or more problems when uploading large files. Setting a large maxrequestlength value does not completely solve the problem, because asp.net blocks the entire file until it is loaded into the memory and then processes it. In fact, if the file is large, we often see that internet explorer displays "the page cannot be displayed-cannot find server or dns error". It seems that this error cannot be caught. Why? Because this is a client side error, the server side applicati
Handling server error when upload file too large
The solution is to use the implicit httpworkerrequest and its getpreloadedentitybody and readentitybody methods to read data from the pipe created by iis for asp.net in blocks.
Copy codeThe Code is as follows:
Iserviceprovider provider = (iserviceprovider) httpcontext. current;
Httpworkerrequest wr = (httpworkerrequest) provider. getservice (typeof (httpworkerrequest ));
Byte [] bs = wr. getpreloadedentitybody ();
....
If (! Wr. isentireentitybodyispreloaded ())
{
Int n = 1024;
Byte [] bs2 = new byte [n];
While (wr. readentitybody (bs2, n)> 0)
{
.....
}
}