WCF web.config 中的 readerQuotas 与请求限制 [英] readerQuotas vs request limit in WCF web.config

查看:45
本文介绍了WCF web.config 中的 readerQuotas 与请求限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望将 100 MB 的数据从客户端应用程序传输到 WCF 服务.我在我的 web.config 中设置了 readerQuotas,但我读了一篇文章,他们建议了 Request Limits,在 http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits 准确的属性是 maxAllowedContentLength.

I wish to transfer 100 MB of data from a client application to a WCF service. I've set readerQuotas in my web.config but I read an article where they suggested Request Limits which is briefly explained in http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits the exact property is maxAllowedContentLength.

我想知道有什么不同之处.

I would like to know what are the differences, please.

<system.serviceModel>

  <bindings>
    <basicHttpBinding>

      <binding name="PowerTransmissionBinding" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
      maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="StreamedRequest" messageEncoding="Mtom">

        <readerQuotas maxDepth="32" maxBytesPerRead="200000000"
        maxArrayLength="200000000" maxStringContentLength="200000000" />

        </binding>
      </basicHttpBinding>
  </bindings>
</system.serviceModel>

请求限制

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="2000000000" />
  </requestFiltering>
</security>

推荐答案

requestLimits 是 Web 服务器级别的设置.当请求的 ContentLength(或 url 长度)超过您在那里设置的限制时 - 请求立即被拒绝并出现 404 错误,它甚至不会进入 WCF 管道.因此,此配置设置与 WCF 完全无关.请注意,它限制了请求的总长度,请求中的内容无关紧要.

requestLimits is a web server level setting. When request comes with ContentLength (or url length) which exceeds the limit you set there - request is immediatly rejected with 404 error, it will not even get into WCF pipeline. So, this configuration setting is not related to WCF at all. Note that it limits the overall length of request, whatever is inside the request does not matter.

readerQuotas 是 WCF 级别设置.它对 WCF 端点可以处理的 SOAP 消息的大小施加了各种限制.请注意,现在它是关于 SOAP(so,xml)消息而不是关于请求的总长度.这些设置基本上需要使用以特殊方式准备的 xml 消息来防止对您的服务的各种拒绝服务攻击.

readerQuotas is WCF level setting. It puts various restrictions on the size of SOAP messages which can be processed by WCF endpoint. Note that now it's about SOAP (so, xml) message and not about overall length of request. Those settings basically needed to prevent various kinds of Denial Of Service attacks against your service using xml messages prepared in a special way.

ma​​xArrayLength - 读取消息时可能返回的数组 xml 读取器的最大大小.这包括字节数组.如果 WCF 读取的数组大于这个,WCF 将停止读取消息并拒绝请求.如果您使用数据联系人类上的 byte[] 属性将文件附加到 WCF 请求 - 这是限制此类文件大小的设置(但最好不要以这种方式附加文件).

maxArrayLength - maximum size of array xml reader may return while reading the message. This includes byte arrays. WCF will stop reading message and reject request if it reads an array bigger that this. If you attach files to your WCF requests using something like byte[] properties on your data contact class - this is the setting which will limit the size of such file (but better not attach files in this way).

ma​​xDepth - 消息中 xml 元素的最大嵌套.

maxDepth - maximum nesting of xml elements in message.

ma​​xNameTableCharCount - 读取器在读取消息时会在内存中存储一​​些信息(例如命名空间和命名空间前缀).这限制了这种内存表的大小.

maxNameTableCharCount - reader will store some information (such as namespaces and namespace prefixes) in memory while reading the message. This limits the size of such in-memory table.

ma​​xStringContentLength - SOAP 消息中字符串的最大长度.假设您有带有一些字符串 DataMember 属性的 DataContract 类.如果在反序列化过程中发生此字符串超出限制 - 消息将被拒绝.

maxStringContentLength - maximum length of a string inside SOAP message. Suppose you have DataContract class with some string DataMember property. If during deserializing it happens that this string exceeds the limit - message would be rejected.

ma​​xBytesPerRead - 基本上是任何 xml 元素(包括它的所有子元素)的最大长度.

maxBytesPerRead - basically maximum length of any xml element (including all it's children).

这篇关于WCF web.config 中的 readerQuotas 与请求限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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