How to use VB. NET to upload large files in ASP. NET

Source: Internet
Author: User
The content here is basically from an article in msdn titled 《

How to upload a file to a Web server in ASP. NET by using Visual Basic. net

", If there is no problem in English, redirect to this article.
IIS 6.0 of Windows2003 imposes a limit on the size of the file to be uploaded, making the server safer. The default asp upload size is 200 kb, and ASP. NET size is 4 MB. There are many articles on the Internet to introduce how to break through the restrictions of IIS 6.0 uploading articles. In fact, it is applicable to file uploads on ASP pages. how to do this in the. NET environment, I used Google to search for one afternoon and did not find a Chinese article. I was helpless. I had to search for the English page when I saw the English, finally, Microsoft found a standard answer on msdn. I do not dare to enjoy it exclusively. I am dedicated to my friends who are not good at English like me.

By default, Asp.. Net allows the file to be uploaded to the Web server to be smaller than or equal to 4096 kb, that is, 4 MB. If the uploaded file is greater than the set value, then, you will see errors such as "no server or DNS is found" on the browser page, which will be confusing to you. If you want to upload a larger file, you must modifyWeb. configFile<Httpruntime>SectionMaxrequestlengthParameter value. If you use vs. Net to create a project, the

For example:

<Httpruntime maxrequestlength = "409600"/>

In this way, the uploaded file can be less than or equal to MB. Files can take effect immediately after they are modified and saved without Restarting IIS.

Sometimes, if we want all the applications on the server to upload large filesMachine. configModify the value of the maxrequestlength attribute in the System Directory\ Microsoft. NET \ framework \Version Number\ Config directory (the bold italic is set according to the specific environment ). For example, in my environment, it should be c: \ windows \ Microsoft. NET \ framework \ v1.1.4322 \ config. It is also set to take effect immediately without Restarting IIS.

Values in Web. config can overwrite the settings in machine. config.

Because ASP. NET first reads the entire file into the memory and then writes it to the disk during upload, uploading too large files will overload the server.

Related Article

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.