Export (0) Print
Expand All
Expand Minimize

TransferMode Enumeration

Indicates whether a channel uses streamed or buffered modes for the transfer of request and response messages.

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

'Declaration
Public Enumeration TransferMode

Member nameDescription
BufferedThe request and response messages are both buffered.
StreamedResponseThe request message is buffered and the response message is streamed.

Silverlight transports support two modes of transferring messages:

  • Buffered transfers hold the entire message in a memory buffer until the transfer is complete.

  • Streamed transfers only buffer the message headers and expose the message body as a stream, from which smaller portions can be read at a time.

Setting the transfer mode to Buffered enables buffered communication in both directions. Setting the transfer mode to StreamedResponse enables streaming communication in the response.

Streamed transfers can improve scalability by eliminating the need for large memory buffers. Whether changing the transfer mode actually improves scalability in practice depends on the size of the messages being transferred. Improvements in scalability should be most evident when large messages use streamed instead of buffered transfers.

By default, the HTTP transport uses buffered message transfers. You can set the value of TransferMode to StreamedResponse on the BasicHttpBinding system-provided binding using the TransferModel property.

For custom built bindings, the transfer mode can be set on the binding element of the transport and this element can then be added to the CustomBinding. For example, create an HttpTransportBindingElement and use the TransferMode property to set the transfer mode when creating a custom binding. The transfer mode can also be set in the configuration section for the custom binding.

The decision to use either buffered or streamed transfers is a local decision of the endpoint for HTTP transports. For HTTP transports, the transfer mode does not propagate across a connection, or to proxy servers or other intermediaries. Setting the transfer mode is not reflected in the description of the service contract. After generating a proxy to a service, you can (it is allowed but not required) edit the configuration file for services intended to be used with streamed transfers to set the transfer mode.

The following code sample shows setting the TransferMode property to StreamedResponse through code:

c#


HttpTransportBindingElement transport = new HttpTransportBindingElement();
transport.TransferMode = TransferMode.StreamedResponse;
BinaryMessageEncodingBindingElement encoder = new BinaryMessageEncodingBindingElement();
CustomBinding binding = new CustomBinding(encoder, transport);

The following sample shows TransferMode property to StreamedResponse through configuration:

<customBinding>
    <binding name="streamingBinding">
        <binaryMessageEncoding />
            <httpTransport transferMode=”StreamedResponse” />
     </binding>
</customBinding>

Silverlight

Supported in: 5, 4

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

Community Additions

ADD
Show:
© 2014 Microsoft