How to manage the ASP.NET web service buffer response

You can use the BufferResponce property to control when the data returned from the web service is sent to the client. The property is set to true by default. In this case the entire result is serialized before it is sent to the client. By setting this property to false, ASP.NET starts returning output as it is serialized.


public byte[] GetLargeStreamOfData()

{ … }

The web service method always finishes executing before anything is returned. The BufferResponse setting applies to the serialization that takes place after the method has executed. With buffering turned off, the first part of the result is serialized and sent. Then the next part of the result is serialized and sent, and so on.

You can set BufferResponse only when the web service returns a large amount of data. This means that the proxy class will still wait for all the information to be received before it passes it back to your application. You can change this behavior by taking direct control over the XML message processing with the IXmlSerializable.