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
Executiontimeout = "300"
Maxrequestlength = "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 value of maxrequestlength 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, application_error on the server side cannot be handled. You can refer to this post to study the mechanism of this error.
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.
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)
{
.....
}
}
Chris Hynes provides us with such a solution (using httpmodule) that allows you to upload large files and display the upload progress in Real Time: