[Import] the server error cannot be found when uploading large files!

Source: Internet
Author: User

The rfc1867 standard can be used to process files:
1. Get the uploaded data at one time and analyze and process it.
Read n moreCodeLater we found that there are currently no ComponentsProgramAnd some COM components use the request. binaryread method. Obtain the uploaded data at a time, and then analyze and process it. This is why the upload of large files is slow. If IIS times out, even if hundreds of MB of files are uploaded, the analysis takes a while.
2. Write to the hard disk while receiving files.

I have learned about commercial components outside China. Some popular components include power-web, aspupload, activefile, abcupload, aspsmartupload, and Sa-fileup. Among them, the better is aspupload and SA-FILE, they claim to be able to process 2 GB of files (SA-FILE EE edition or even no file size restrictions), and the efficiency is also very good, isn't itProgramming LanguageIs the efficiency so low? I checked some information and thought they were all operating directly.CompositionComponent stream. In this way, the file size is not restricted. However, it is not absolutely perfect for foreigners. After aspupload processes large files, the memory usage is astonishing. Around 1 GB is common. As for SA-FILE although it is good but difficult to find the crack. Then we found two. Net Upload components, lion. Web. uploadmodule and aspnetupload, which are also operation file streams. However, the upload speed and CPU usage are not as good as the commercial components of foreigners.
A test was conducted to upload 1 GB files in the LAN. The average upload speed of aspupload is 4.4 Mb/s, the CPU usage is 10-15, and the memory usage is 700 mb. SA-FILE is almost like this. The aspnetupload is only 1.5 m/s at the fastest, with an average of 700 K/s and CPU usage of 15-39. test environment: piii800, 100 m memory, and m lan. I think the slow speed of aspnetupload may be caused by hard disk writing while receiving files. The low cost of resource occupation is to reduce the transmission speed. But I also have to admire the foreign program. The CPU usage is so low .....

Iii. ASP. NET File Upload Problems
We have encountered one or more problems when uploading large files using ASP. NET. 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.
Iv. ASP. NET large file upload Solution
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. 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.
Lion. Web. uploadmodule and aspnetupload both use this solution.

Solution Principle:
Httphandler is used to implement functions similar to ISAPI extention, process request information and send response ).

Solution highlights:
1. httphandler or httpmodule
A. The request object is intercepted before the Asp.net process processes the request.
B. Read and Write Data in Parts
C. Track the upload progress in real time and update the meta information.
2. Use the implicit httpworkerrequest to process the file stream using its getpreloadedentitybody and readentitybody methods.

========================================================== ==================================
I have forgotten where the above description was found. It is clear about the uploading of large files in Asp.net. I just want to explain one problem here:

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.

I tried many times and found that this error is indeed on the server side, this is my proof:
11/7/2005 11:07:13 am aa8b180d-a91e-4734-938f-00c066b4993b: aa8b180d-a91e-4734-938f-00c066b4993b.doc
11/7/2005 11:08:07 am start upload .......
11/7/2005 11:08:11 am httpmodule error .....
11/7/2005 11:09:31 am start upload .......
11/7/2005 11:09:44 am httpmodule error .....
11/7/2005 11:10:43 am start upload .......
11/7/2005 11:10:46 am 55007: 49152
11/7/2005 11:10:46 am ----------------------------- 7d531c2e1705ac
both times, the program encountered an error because I uploaded a large file. This error is not handled using try and catch blocks, but in
private void webbupload_error (Object sender, eventargs E)
{< br> # region function webbupload_error
webbtexttrace. tracemsg ("httpmodule error ..... ");
# endregion
This. dispose ();
}< br> that is to say, when we upload a large file, the server quickly detects the file size and returns an error. It turns out that I can only upload half of the files each time. What is the problem?

If we do not write the httpmodule on our own, the server has its own processing module. In this case, we can only upload small files. If the file server is too large, an error will occur.
If we write the httpmodule ourselves, isn't this error necessarily true? Not necessarily, I encountered this problem several times during the test because I was processing the file stream or it was not an issue with Asp.net's httpmodul, but some exceptions (. net), which is exactly ours. the managed code on the. NET platform cannot catch exceptions, which can only be captured by the unmanaged module of IIS. Therefore, the returned result is an error not found on the server.

Therefore, if such an error occurs and you write your own httpmodul module according to the above method, the problem cannot be solved, that is, it occurs in your module. net incompatibility exception, which causes the above error. The exceptions that cannot be captured by. Net can be affirmed: it must be a problem with your program. Therefore, be careful when detecting the code ..

I have encountered several errors in these places:
1. An error occurred while reading data in a byte loop.
2. Zero division error at a time (this can be captured, but no. I don't know why ?)
3. Resource locking error. Specifically, I cannot remember what the error was, because each time it was just an error that could not be found by the server, I could only find the problem by searching the code manually, then I guess...
There are some problems with the exception mechanism of. Net itself, especially in hosting compatibility.

Okay, hope this articleArticleCan help some people...

 

Source: http://computer.mblogger.cn/wucountry/posts/48676.aspx

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.