logo

Thông báo

Icon
Error

Chia sẻ
Tùy chọn
Xem
Xem bài viết cuối
Offline admin  
#1 Đã gửi : 18/04/2017 lúc 07:30:11(UTC)
admin

Danh hiệu: Administration

Chức danh:

Nhóm: Administrators
Gia nhập: 23-07-2013(UTC)
Bài viết: 5,754
Man
Viet Nam
Đến từ: Vietnam

Cảm ơn: 8 lần
Được cảm ơn: 2 lần trong 2 bài viết

FIX "THE REQUEST FILTERING MODULE IS CONFIGURED TO DENY A REQUEST THAT EXCEEDS THE REQUEST CONTENT LENGTH" IIS ERROR

Issue
If you are using IIS Web server for hosting your application, Sometimes these kind of error can be trigger when try to upload a large file using your application.

  • "The request filtering module is configured to deny a request that exceeds the request content length."
  • "System.Web.HttpException: Maximum request length exceeded."

Reason

Default IIS settings only allow to upload up to  4Mb large files. Rest are filtered and shows the one of above error.

Solution

Solution is you need to increase default max allow file size to what ever you want size. This can be do in two levels

  1. Application level
  2. Server level

 Lets see how to do each. first we are going to look at "Application Level" configuration changes.

1. Application Level

Step1:

Go to  "Control Panel" -> "Administrative Tools" ->" Internet Information Services (IIS) Manager"

Step2: 

Expand the connection explorer and double click on the site you working on.

Step 3:

In the right hand panel, you can see the set of icons under few categories, Go to category Management and double click on the "configuration editor icon". 

Step 4:

Then the configuration editor window will appear and you have to click the link "Search Configuration" at right hand side pane.

Step 5: 

Then "Configuration Search" dialog will appear and first you have to select the "web.config" file and then click the link on right bottom of the dialog.

Step 6:

Then "web.config" file will open in your default XML editor and it shows all the configuration that applicable to particular web site. So now we are going to add default upload limit configuration to MySite01, to override default server configuration.Here I need to allow file upload until 1GB (1*1024*124 = 1048576 KB) size. So what i need to do is just copy and paste following piece of code to the "web.config" file just after start the <configuration> tag.

Mã:
<system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2147483648"/>
      </requestFiltering>
    </security>
  </system.webServer>
  <system.web>
    <httpRuntime maxRequestLength="1048576" />
  </system.web>

Step 6: 

Then your file should looks like this. Be careful someone may be previously added the same configuration to this file. At that situation you have to edit the values instead of newly adding.

Step7: 

Now you edit the configuration. But to apply these configurations you have to restart the IIS server. To do so run the command prompt as Administrator (click start button-> type cmd in search box -> once you see the command prompt icon -> right click and select "Run as administrator"). Type iisresetand press enter.

2. Server Level

Setp 1:

Open the command prompt as administrator (click start button-> type cmd in search box -> once you see the command prompt icon -> right click and select "Run as administrator") and go to c:\Windows\System32\inetsrv directory

Step 2:  Type the following command and press enter

appcmd.exe unlock config -section:system.webServer/security/requestFiltering

Step 3:

If your command is correct and worked properly you can see a result like following window. Actually here disabling the file size validation. But not, increasing the allowed max file size.

Step 4:

Now you edit the configuration. But to apply these configurations you have to restart the IIS server. Type iisreset and press enter.

Source: http://codeketchup.blogspot.com

Ai đang xem chủ đề này?
OceanSpiders 2.0
Di chuyển  
Bạn không thể tạo chủ đề mới trong diễn đàn này.
Bạn không thể trả lời chủ đề trong diễn đàn này.
Bạn không thể xóa bài của bạn trong diễn đàn này.
Bạn không thể sửa bài của bạn trong diễn đàn này.
Bạn không thể tạo bình chọn trong diễn đàn này.
Bạn không thể bỏ phiếu bình chọn trong diễn đàn này.

Powered by YAF.NET 2.2.3 | YAF.NET © 2003-2018, Yet Another Forum.NET
Thời gian xử lý trang này hết 0.239 giây.