. NET file attachment upload size limit control

Source: Internet
Author: User

1. Files of 4 MB can be uploaded by default.

Modify the Machine. config file to change the value of the MaxRequestLength parameter. Search for this file in the c: \ winnt \ microsoft.net directory.

Note that when saving the file, you should ensure that the complete path of the specified file (for example, "C: \ MyFiles \ Picture.jpg") and ASP. the account used by. NET provides the write permission for the directory to store files. When uploading a large file, you can use the maxRequestLength attribute of the element to increase the maximum file size. For example:

<Configuration>
<System. web>
<HttpRuntime maxRequestLength = "1048576" executionTimeout = "3600"/>
</System. web>
</Configuration>

MaxRequestLength indicates the maximum number of bytes uploaded in HTTP mode supported by ASP. NET. This restriction can be used to prevent DoS attacks caused by a large number of files being transferred to the server. The specified size is in KB. The default value is 4096 KB (4 MB ). ExecutionTimeout: indicates the maximum number of seconds allowed to execute a request before it is automatically disabled by ASP. NET. When the file size exceeds the specified size, if a DNS error occurs in the browser or the service is unavailable, modify the above configuration to increase the number of configurations.

2. Another problem

When uploading a large file, you may receive the following error message:

Aspnet_wp.exe (PID: 1520) is recycled because the memory consumption exceeds 460 MB (60 percent of available RAM ).

If this error message is returned, add the value of the memoryLimit attribute in the element of the Web. config file of the application. For example:

<Configuration>
<System. web>
<ProcessModel memoryLimit = "80"/>
</System. web>
</Configuration>

For Windows Server2003:

Precautions for uploading large files on Windows Server 2003:

When a large attachment is uploaded on Windows Server 2003, The system reports an error:
1. Disable the iis admin service in the service first.
2. Find MetaBase. xml under WINDOWS \ system32 \ inetsrv,
Open and find ASPMaxRequestEntityAllowed to change it to the required value. The default value is 204800, that is, 200 K. Change it to 51200000 or greater [Determined by file size].
3. Restart the iis admin service.

Article Source: http://www.diybl.com/course/4_webprogram/asp.net/asp_netshl/2008318/105040.html

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.