哪个获得优先级,maxRequestLength 或 maxAllowedContentLength? [英] Which gets priority, maxRequestLength or maxAllowedContentLength?

查看:35
本文介绍了哪个获得优先级,maxRequestLength 或 maxAllowedContentLength?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在更改允许上传的最大文件大小时,我偶然发现了这两个设置.

While changing the maximum allowed file size for upload I stumbled on those two settings.

sytem.web 中,您有带有 ma​​xRequestLengthhttp 运行时 节点.在 system.webServer 中,您有 requestLimitsma​​xAllowedContentLength.

In the sytem.web you have the http runtime node with maxRequestLength. In the system.webServer you have the requestLimits with maxAllowedContentLength.

现在哪个优先于另一个?我们需要同时设置还是最后一个(IIS7 的一个)就足够了?

Now which gets the priority over the other? And do we need to set both or is the last one (the one for IIS7) enough?

推荐答案

maxRequestLength 表示 ASP.NET 支持的最大请求大小,而 maxAllowedContentLength 指定 IIS 支持的请求中的最大内容长度.因此,您需要同时设置两者才能上传大文件:较小的优先".

maxRequestLength indicates the maximum request size supported by ASP.NET, whereas maxAllowedContentLength specifies the maximum length of content in a request supported by IIS. So you need to set both in order to upload large files: the smaller one "takes priority".

(我从 http://forums.iis.net/t/1169846.aspx-- 应有的信用.)

(I picked this up from http://forums.iis.net/t/1169846.aspx -- credit where it's due.)

您可以通过编辑适当的 web.config 文件将两者设置为特定站点的本地或站点内的文件夹.如果文件(好吧,请求)长度小于 maxAllowedContentLength 但大于 maxRequestLength,用户将获得您的标准 (ASPX) 错误页面(如果您有的话).如果相反,他会得到一个 IIS 错误页面.因此,您可能希望将 maxAllowedContentLength 设置为一个非常大的值(仅针对此网站/文件夹),然后将限制值设置为 maxRequestLength.

You can set both to be local to a specific site or even a folder within a site by editing the appropriate web.config file. If the file (well, request) length is less than maxAllowedContentLength but more than maxRequestLength, the user will get your standard (ASPX) error page, if you have one. If it's the other way around, he'll get an IIS error page instead. For that reason, you might want to have maxAllowedContentLength to a very large value (just for this website/folder) and then have the limiting value be maxRequestLength.

最后,记住 maxRequestLength 的单位是 KB 而 maxAllowedContentLength 的单位是 BYTES!

Finally, remember that maxRequestLength is in KB whereas maxAllowedContentLength is in BYTES!

这篇关于哪个获得优先级,maxRequestLength 或 maxAllowedContentLength?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆