Maximum size setting for IIS7 file uploads

Source: Internet
Author: User
Tags stack trace

When uploading a file exceeding 30M, the server redirects to 404.13 pages with the following error:

HTTP Error 404.13-not Found
The request filtering module is configured to deny a request of that exceeds the request content length.
This is because the server limits the maximum file size that can be uploaded. Its value in

Configuration/system.webserver/security/requestfiltering/requestlimits@maxallowedcontentlength setting

In the ApplicationHost.config or Web.config file. Defined in.

To view the applicationhost.config in the C:windowssystem32inetsrvconfig directory, you can

system.webserver/security/requestfiltering/found in the requestlimits settings, if not, you can add the following: (This

The units in maxAllowedContentLength are bytes. )

The code is as follows Copy Code

<system.webServer>
<security>
<requestFiltering>
<requestlimits maxallowedcontentlength= "40000000"/>
</requestFiltering>
<security>
<system.webServer>

You can also modify applicationhost.config by using command-line mode:

The code is as follows Copy Code

%windir%system32inetsrvappcmd Set Config-section:requestfiltering-

requestlimits.maxallowedcontentlength:40000000

After this setting, the server's size limit for uploaded files will be 40000000bytes. Of course, this setting is server-level, if you want to

Limiting the size of a site or an application can also be done in the same way, except that the web.config is set in the site.

But you have to make this change to make sure that the permissions on the changes in the ApplicationHost.config have been released. You can make changes by setting the following settings:

The code is as follows Copy Code

Modify the Overridemodedefault from ' Deny ' to ' Allow ' like so:

<sectiongroup name= "system.webserver" >
<section name= "requestfiltering" overridemodedefault= "Allow"/>
</sectionGroup>

After you have modified the above settings in ApplicationHost.config, make the following settings.

Find the web.config of the application and modify it as described above:

The code is as follows Copy Code

<system.webServer>
<security>
<requestFiltering>
<requestlimits maxallowedcontentlength= "40000000"/>
</requestFiltering>
<security>
<system.webServer>

Alternatively, you can also use the command line form:

The code is as follows Copy Code

%windir%system32inetsrvappcmd set config "Default Web site/<your app>"-section:requestfiltering-

requestlimits.maxallowedcontentlength:40000000

In this way, you can set up for an application on a site.

However, the developer is web.config in the following settings:

The code is as follows Copy Code

<system.web>

Executiontimeout= "/>"

</system.web>

Here's maxRequestLength according to MSDN Introduction: Gets or sets the maximum request size. The maximum request size in

Kilobytes. The default size is 4096 KB (4 MB).

The maxRequestLength property specifies the limit for the buffering threshold of the input stream. For

example, this limit can is used to prevent denial of service attacks (Denial of service attack) that are caused by

The users who post large files to the server.

The value assigned to this property should is greater or equal to value assigned to the

Requestlengthdiskthreshold property.

But this setting for developers doesn't seem to work. Here they are, limit the maximum request length to 40MB and timeout to 120s.

Next time, look at what the specific setting is for.

-------------------------

Now I get it. This is used to set the maximum length of a single request. For example, if the maxRequestLength is set to 30M in Emailticket,

maxAllowedContentLength is 40M,

Then in reply email, select a 35M attachment, when clicked Save as draft, the length of this request will probably have 35M, this has

Surpassed the maxRequestLength. At this point the request will be an error, the result is the Yellow pages:

Server Error in '/emailticket ' application.

--------------------------------------------------------------------------------

Maximum request length exceeded.
Description:an unhandled exception occurred during the execution of the current Web request. Please

Review the stack trace for more information about the error and where it originated in the code.
Exception Details:System.Web.HttpException:Maximum request length exceeded.

Another solution

In Win2008, open the IIS7, find the site that needs to be modified, double-click the "Configuration Editor" under "Administration" on the right, and in the section above,

Find "system.webserver-->webdav-->asp", at which point "system.webserver/asp" is displayed in the section.

In the following, find "Limits", click on the left side of the plus, change "bufferinglimit" and "maxrequestantityallowed" values are

"2000000000" (2G, the maximum is 2G), change the return, click on the right side of the top "operation" under the "Application." Congratulations, it's done!


Note: asp.net (IIS 7 and IIS 7.5) cannot upload a file with a maximum value of 2GB


If you are ASP is not asp.net we can refer to the following method to set

, Stop IIS7

2, find "C:windowssystem32inetsrvconfigschemaiis_schema.xml" file.

This file is read-only and cannot be modified with administrator privileges. To modify the permissions of the file first, and then remove the read-only property.

1. Right key file-> attribute-> security, select Target user, click Advanced, modify file owner;

2. After the confirmation click Edit, you can modify the current user's permissions, add "Write" permission. At this point, the permission settings are OK.

3. Remove the read-only property of the file.

Open the file in Notepad, find "", and Change "30000000" to the value you want (for example, 2000000000) to save.

Add a read-only property to the "C:windowssystem32inetsrvconfigschemaiis_schema.xml" file.

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.