Where to control the size of uploaded files in web.config:
Copy Code code as follows:
maxRequestLength is the maximum size (in kilobytes) of the request to control the upload size. The default size is 4096 KB (4 MB). Executiontimeout indicates the maximum number of seconds that are allowed to be performed before the request is asp.net automatically closed. The default value is 90 seconds. The unit is seconds. You can see MSDN in detail.
Http://msdn.microsoft.com/zh-cn/library/system.web.configuration.httpruntimesection.maxrequestlength%28v=VS.80%29.aspx
Resolve asp.net upload file size limit
For ASP.net, the default is to upload only 2m files, add the following configuration, you can generally customize the maximum file size.
If not, you can use the scenario provided by Shi:
We have had this or that problem when uploading large files. Setting a large maxRequestLength value does not completely solve the problem, because ASP.net blocks until the entire file is loaded into memory and then processed. In fact, if the file is very large, we often see Internet Explorer display "The page cannot be Displayed-cannot find server or DNS error", as if it could not catch this error 。 Why? Because this is a client side error, the server side end of the Applicati
Handling server error when upload file too large
The solution is to use the implied httpworkerrequest, using its getpreloadedentitybody and Readentitybody methods to read data from the pipe built by IIS for asp.net
Copy Code code 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)
{
.....
}
}