다음을 통해 공유


BasicHttpBinding.MaxReceivedMessageSize Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the maximum size for a message that can be received on a channel configured with this binding.

Namespace:  System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

Syntax

'Declaration
Public Property MaxReceivedMessageSize As Long
public long MaxReceivedMessageSize { get; set; }

Property Value

Type: System.Int64
The maximum size, in bytes, for a message that is processed by the binding. The default value is 65,536 bytes.

Exceptions

Exception Condition
ArgumentOutOfRangeException

The value is less than zero.

Remarks

The size of the messages that can be received on the wire by clients using the BasicHttpBinding is bounded by the amount of memory allocated for each message. This bound on message size is intended to limit exposure to DoS-style attacks.

There is also a MaxBufferSize property on the BasicHttpBinding that gets or sets the maximum size for a buffer on the client that receives messages from the channel.

Examples

            ' Get default MaxReceivedMessageSize
            Dim maxReceivedBufferSize As Long = binding.MaxReceivedMessageSize
            'Output of txtMBS: 65536
            Dim txtMRBS As String = maxReceivedBufferSize.ToString()

            ' Set new MaxReceivedMessageSize
            binding.MaxReceivedMessageSize = 4096
            Dim txtNewMRBS As String = binding.MaxReceivedMessageSize.ToString()
// Get default MaxReceivedMessageSize
long maxReceivedBufferSize = binding.MaxReceivedMessageSize;
//Output of txtMBS: 65536
string txtMRBS = maxReceivedBufferSize.ToString();

// Set new MaxReceivedMessageSize
binding.MaxReceivedMessageSize = 4096;
string txtNewMRBS = binding.MaxReceivedMessageSize.ToString();

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.