BasicHttpBinding.MaxReceivedMessageSize BasicHttpBinding.MaxReceivedMessageSize BasicHttpBinding.MaxReceivedMessageSize BasicHttpBinding.MaxReceivedMessageSize Property

定义

获取或设置配置了此绑定配置的通道上可以接收的消息的最大大小(以字节为单位)。Gets or sets the maximum size, in bytes, for a message that can be received on a channel configured with this binding.

public:
 property long MaxReceivedMessageSize { long get(); void set(long value); };
public long MaxReceivedMessageSize { get; set; }
member this.MaxReceivedMessageSize : int64 with get, set
Public Property MaxReceivedMessageSize As Long

属性值

绑定可处理的最大消息大小(以字节为单位)。The maximum size, in bytes, for a message that is processed by the binding. 默认值为 65,536 字节。The default value is 65,536 bytes.

异常

示例

下面的示例将 MaxReceivedMessageSize 设置为1000000字节。The following example sets MaxReceivedMessageSize to 1,000,000 bytes.

BasicHttpBinding binding = new BasicHttpBinding();

// Use double the default value
binding.MaxReceivedMessageSize = 65536 * 2;

也可以在配置文件中设置此属性的值。The value of this property can also be set in the configuration file.

<configuration>
  <system.serviceModel>

    <bindings>
      <basicHttpBinding>
        <binding name="Binding1"
                 maxReceivedMessageSize = "1000000">
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>

  </system.serviceModel>

</configuration>

注解

使用 BasicHttpBinding 的服务可以在网络上接收的消息的大小受为每条消息分配的内存量的限制。The size of the messages that can be received on the wire by services using the BasicHttpBinding is bounded by the amount of memory allocated for each message. 对消息大小进行的此限制旨在降低遭受拒绝服务 (DoS) 攻击的可能性。This bound on message size is intended to limit exposure to DoS-style attacks.

MaxBufferSize 上还有 BasicHttpBinding 属性:There is also a MaxBufferSize property on the BasicHttpBinding:

对于缓冲传输,(TransferMode 设置为 Buffered)。For buffered transports, (TransferMode set to Buffered). 此值始终等于 MaxReceivedMessageSize 指定的值。This value is always equal to that specified by the MaxReceivedMessageSize.

对于流传输(TransferMode 设置为 Streamed),必须对 SOAP 标头进行缓冲才能生成消息。For streamed transports (TransferMode set to Streamed), only the SOAP headers must be buffered to generate the message. 可根据需要对正文进行流处理。The body can be streamed in on-demand. 在这种情况下,MaxBufferSize 小于或等于 MaxReceivedMessageSize,其中 MaxReceivedMessageSize 限制整个消息(标头和正文)的大小,而 @no__t SOAP 标头的大小。In this case, MaxBufferSize is less than or equal to MaxReceivedMessageSize, where MaxReceivedMessageSize bounds the size of the overall message (headers and body) and MaxBufferSize bounds the size of the SOAP headers.

适用于