. Net mvc exceeds the maximum length of the request.
As shown in "The maximum request length is exceeded" in our project, this is because the default Request Length of IIS is 4 MB. When the request length is greater than this value, an error is reported. The following is a solution.
Solution: Modify the web. config file
1. Note that there are two web. config files in mvc. For example, one is located under Views, which is used to control the files in view. The other is located under the root directory and takes effect on all files. Modify web. config in the root directory.
2. Modify maxRequestLength: In web. config, modify maxRequestLength in <system. web> </system. web> to indicate the maximum request length. The unit is kb. The default value is 4 MB.
<System. web> <! -- Maximum request length, in kb -->
3. Modify maxAllowedContentLength: In web. config, modify <system. webServer> </system. webServer>MaxAllowedContentLengthIndicates the maximum attachment size. The unit is bytes. The default value is about 30 mb.
<System. webServer> <! -- The length of the file to be uploaded, in bytes --> <security> <requestFiltering> <requestLimits maxAllowedContentLength = "20971520"/> </requestFiltering> </security> </system. webServer>
Note:Differences between maxRequestLength and maxAllowedContentLength
A. The former indicates the request length, and the latter indicates the size of the uploaded file;
B. Unit: kb; Unit: bytes;
C. The former defaults to 4 M, and the latter defaults to B, about 30 M;
D. the maximum values of the two are 2 GB.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.