设置IIS7文件上传的最大大小 maxAllowedContentLength,maxRequestLength
当上传一个超过30M的文件时,服务器会重定向至404.13页面,报错如下:
HTTP Error 404.13 - Not Found
The request filtering module is configured to deny a request that exceeds the request content length.
这是由于服务器限制了所能上传文件的最大值。其值在configuration/system.webServer/security/requestFiltering/requestLimits@maxAllowedContentLength setting in the applicationhost.config or web.config file. 中定义。
查看C:\Windows\System32\inetsrv\config目录下的applicationhost.config,可以在system.webServer/security/requestFiltering/中找到requestLimits设置项,若没有,则可以自行添加如下:(这里maxAllowedContentLength的单位为bytes。)
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="40000000" />
</requestFiltering>
<security>
<system.webServer>
也可以使用命令行模式修改applicationhost.config为:
%windir%\system32\inetsrv\appcmd set config -section:requestFiltering -requestLimits.maxAllowedContentLength:40000000
经过这个设置后,服务器对上传文件的大小限制将变为40000000bytes了。当然,这个设置是服务器级别的,如果你想在某个站点或者某个应用上限制大小,也可以通过以相同方式进行设置,只不过这次设置的是站点内的Web.config。
但是你要进行此项修改,要确保applicationhost.config中对该项修改的权限已经放开。可通过如下设置进行更改:
modify the overrideModeDefault from "Deny" to "Allow" like so:
<sectionGroup name="system.webServer">
<section name="requestFiltering" overrideModeDefault="Allow" />
</sectionGroup>
确认修改过applicationhost.config中上述设置以后,再进行如下设置。
找到应用的Web.config,按上述进行修改:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="40000000" />
</requestFiltering>
<security>
<system.webServer>
或者你也可以通过命令行的形式:
%windir%\system32\inetsrv\appcmd set config "Default Web Site/<your app>" -section:requestFiltering -requestLimits.maxAllowedContentLength:40000000
这样,你就能针对某个站点的某个应用进行设置。
但是开发人员是在Web.Config中进行了如下设置:
<system.web>
<httpRuntime maxRequestLength="40960" appRequestQueueLimit="100" useFullyQualifiedRedirectUrl="true" executionTimeout="120" />
</system.web>
这里的maxRequestLength据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. For example, this limit can be used to prevent denial of service attacks(拒绝服务攻击) that are caused by users who post large files to the server.
The value assigned to this property should be greater or equal to value assigned to the RequestLengthDiskThreshold property.
但是开发人员的这个设置好像是不起作用的。他们在这里,限制最大请求长度为40MB,超时为120s。
下次再看一下具体这个设置是用来做什么的。
-------------------------
现在明白了。这个是用来设置单个请求的最大长度。比如EmailTicket中若设置maxRequestLength为30M,maxAllowedContentLength为40M,
然后在Reply Email时,选择了一个35M的附件,在点击Save as Draft的时候,这个请求的长度大概会有35M,这个已经超过了maxRequestLength。此时请求就会报错了,结果是黄页:
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.
所以,最好是maxRequestLength和maxAllowedContentLength设置为一致的值。
设置IIS7文件上传的最大大小 maxAllowedContentLength,maxRequestLength的更多相关文章
- PHP设置图片文件上传大小的具体实现方法
PHP默认的上传限定是最大2M,想上传超过此设定的文件,需要调整PHP.apache等的一些参数 我们简要介绍一下PHP文件上传涉及到的一些参数: •file_uploads :是否允许通过HTTP上 ...
- WebUploader 设置单个文件上传
1.导入控件样式文件 <link rel="stylesheet" type="text/css" href="__PUBLIC__/stati ...
- C#模拟请求,模拟登录,Cookie设置、文件上传等问题汇总
由于业务需求,最近需要模拟完成登陆某个网站,并上传所需要的文件.在开发途中,遇到了很多问题,现在,就我遇到的一些问题及解决办法说明如下,希望对遇到同样问题的人有所帮助.因为技术有限,可能有些内容并不完 ...
- SpringBoot 2.x版本+MultipartFile设置指定文件上传大小
SpringBoot-versio:2.1.9-RELEASE 由于新版本的SpringBoot已经弃用了如下, 这种方式,提供了新的 配置方案. 这个是官方的介绍 Handling Multipar ...
- element-ui文件上传 做类型大小的限制
上代码: <div class="filebox"> <el-upload class="upload-demo" :action=" ...
- 【转载】Git设置单个文件上传大小
git单个文件默认大小是50M,超过50M,会给出warning.大于100M会无法提交: 可以通过命令,修改单个文件默认大小(以设置500M以例): git config --global http ...
- SpringBoot学习6:springboot文件上传
1.编写页面uploadFile.html <!DOCTYPE html> <html lang="en"> <head> <meta c ...
- SpringMVC(三) RESTful架构和文件上传下载
RESTful架构 REST全名为:Representational State Transfer.资源表现层状态转化.是目前最流行的一种互联网软件架构. 它结构清晰.符合标准.易于理解.扩展方便,所 ...
- SpringBoot: 6.文件上传(转)
1.编写页面uploadFile.html <!DOCTYPE html> <html lang="en"> <head> <meta c ...
随机推荐
- poj 1087.A Plug for UNIX (最大流)
网络流,关键在建图 建图思路在代码里 /* 最大流SAP 邻接表 思路:基本源于FF方法,给每个顶点设定层次标号,和允许弧. 优化: 1.当前弧优化(重要). 1.每找到以条增广路回退到断点(常数优化 ...
- 『重构--改善既有代码的设计』读书笔记----Remove Middle Man
如果你发现某个类做了过多的简单委托动作,你就可以考虑是否可以让客户直接去调用受托类.在Hide Delegate中,我们介绍了封装受托对象的好处,但好处归好处也存在代价,就是当你每次需要在受托对象中增 ...
- Android 动画效果 及 自定义动画
1. View动画-透明动画效果2. View动画-旋转动画效果3. View动画-移动动画效果4. View动画-缩放动画效果5. View动画-动画效果混合6. View动画-动画效果侦听7. 自 ...
- eclipse 比较好的插件
tomcat 插件 egit github 插件 subeclipse 插件 Properties Editor Properties Editor 编辑java的属性文件,并可以自动存盘为Unico ...
- 概率质量函数:怀孕周期的PMF
__author__ = 'dell' import surveyimport Pmfimport matplotlib.pyplot as pyplot table = survey.Pregnan ...
- jQuery常用特效插件汇总
jquery的CDN引用及下载地址 http://www.bootcdn.cn/jquery/ 1:semantictabs.js可以简单地制作Tabs菜单2:tabBox.js可以非常简单方便地 ...
- cf C. Arithmetic Progression
http://codeforces.com/contest/382/problem/C 题意:给你n个数,然后让你添加一个数使得n+1个数能形成这样的规律,a[1]-a[0]=a[2]-a[1]=a[ ...
- dwr消息推送和tomcat集群
网友的提问: 项目中用到了dwr消息推送.而服务端是通过一个http请求后 触发dwr中的推送方法.而单个tomcat中.服务器发送的http请求和用户都在一个tomcat服务器中.这样就能精准推送到 ...
- C++ primer读书笔记 chapter3 标准库类型
除第二章介绍的是C++的基本类型,本章将大致介绍一下C++定义的内容丰富的抽象数据库类型标准库.着重介绍一下sting.vector和bitset. 3.2标准库string类型 1.string类型 ...
- P1894セチの祈り
描述 在 Ninian 的花园里,有许多琼花,环绕着中间的凉亭.有 N 片琼花,组成一个环.Ninian 想在凉亭中发动 [セチの祈り] , 需要划分出三个区域的琼花,为了平均,要最大化面积最小的区域 ...