IIS7 maximum file upload size settings

Source: Internet
Author: User

We know that to set the size of the uploaded file in iis7, we only need to modify two parameters: maxRequestLength and maxAllowedContentLength. The following is a reference.

When uploading a file larger than 30 mb, the server redirects to the 404.13 page and reports the following error:

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

Configuration/system. webServer/security/requestFiltering/requestLimits @ maxAllowedContentLength setting

Defined in the applicationhost. config or web. config file.

View applicationhost. config in the C: WindowsSystem32inetsrvconfig directory.

The requestLimits setting item is found in system. webServer/security/requestFiltering/. If not, you can add the following items:

The unit of maxAllowedContentLength in is bytes .)

The Code is as follows: Copy code

<System. webServer>
<Security>
<RequestFiltering>
<RequestLimits maxAllowedContentLength = "40000000" type = "codeph" text = "/codeph"/>
</RequestFiltering>
<Security>
<System. webServer>

You can also use the command line mode to modify applicationhost. config:

The Code is as follows: Copy code

% Windir % system32inetsrvappcmd set config-section: requestFiltering-

RequestLimits. maxAllowedContentLength: 40000000

After this setting, the server will change the file size limit to bytes. Of course, this setting is at the server level. If you want

You can set the size of a website or application in the same way, but this time you set the Web. config in the site.

However, you need to make this modification. Make sure that the permission for this modification has been released in applicationhost. config. You can change the settings as follows:

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, perform 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" type = "codeph" text = "/codeph"/>
</RequestFiltering>
<Security>
<System. webServer>

Or you can use the command line format:

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 an application for a website.

 

However, the developer made the following settings in Web. Config:

The Code is as follows: Copy code

<System. web>

<HttpRuntime maxRequestLength = "40960" appRequestQueueLimit = "100" useFullyQualifiedRedirectUrl = "true"

ExecutionTimeout = "120"/>

</System. web>

MaxRequestLength here according to MSDN: 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.

Example, this limit can be used to prevent denial of service attacks (denial of service Attack) that are caused

Users who post large files to the server.

The value assigned to this property shoshould be greater or equal to value assigned to

RequestLengthDiskThreshold property.

However, this setting does not seem to work for developers. Here, the maximum request length is 40 MB and the timeout value is 120 s.

Next, let's take a look at what this setting is.

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

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

MaxAllowedContentLength is 40 M,

Then, during Reply Email, A 35 MB attachment is selected. When you click Save as Draft, the request length will be about 35 MB.

MaxRequestLength is exceeded. In this case, an error is returned, and the result is 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 IIS7, find the website for which you want to modify the restriction, double-click the "configuration Editor" under "manage" on the right, and in the "section" above,

Find "system. webServer --> webdav --> asp". Then, "system. webServer/asp" is displayed in the "section ".

Find "Limits" below, click the plus sign on the left, and change the value of "bufferingLimit" and "maxRequestAntityAllowed"

"2000000000" (2G, the maximum value is 2G). After modification, press enter and click "application" under "operation" at the top of the right sidebar ". Congratulations!


Note: the maximum size of files uploaded by asp.net (IIS 7 and IIS 7.5) cannot exceed 2 GB.


If asp is not asp.net, we can refer to the following method to set

Stop IIS7

2. Find the "C: WindowsSystem32inetsrvconfigschemaIIS_schema.xml" file.

This file is read-only, that is, the Administrator permission cannot be modified. You must first modify the File Permission and then remove the read-only attribute.

1. Right-click a file and choose Properties> Security. Select the target user and click Advanced to modify the file owner;

2. Click "edit" to modify the permissions of the current user and add the "write" permission. Now, the permission settings are OK.

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

Open the file in notepad, find "", and change "30000000" to the desired value (for example, 2000000000) and save it.

Add the read-only attribute 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.