BasicHttpBinding.MaxReceivedMessageSize 屬性

定義

取得或設定可在使用此繫結所設定之通道上接收的訊息大小上限 (以位元組為單位)。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.

例外狀況

這個值小於零。The value is less than zero.

範例

下列範例會將 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.

MaxBufferSizeBasicHttpBinding上也有 {3} 屬性: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 會限制整體訊息的大小(標頭和主體),而 MaxBufferSize 會限定 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.

適用於