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.