HttpWebRequest.AllowWriteStreamBuffering Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets or sets a value that indicates whether to buffer the data sent to the Internet resource.

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

public virtual bool AllowWriteStreamBuffering { get; set; }

Property Value

Type: System.Boolean

true to enable buffering of the data sent to the Internet resource; false to disable buffering. The default is true.

When AllowWriteStreamBuffering is true, the data is buffered in memory so it is ready to be resent in the event of redirections or authentication requests.

Notes to Implementers:

Setting AllowWriteStreamBuffering to true might cause performance problems when uploading large datasets because the data buffer could use all available memory.

The following code example uses the AllowWriteStreamBuffering property to disable data buffering.

// Create a new 'HttpWebRequest' object to the mentioned Uri.				
HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create("");
// Set AllowWriteStreamBuffering to 'false'. 
Console.WriteLine("\nPlease Enter the data to be posted to the ( uri:");
string inputData =Console.ReadLine();
string postData="firstone="+inputData;
// Set 'Method' property of 'HttpWebRequest' class to POST.
ASCIIEncoding encodedData=new ASCIIEncoding();
byte[]  byteArray=encodedData.GetBytes(postData);
// Set 'ContentType' property of the 'HttpWebRequest' class to "application/x-www-form-urlencoded".
// If the AllowWriteStreamBuffering property of HttpWebRequest is set to false,the contentlength has to be set to length of data to be posted else Exception(411) is raised.
Stream newStream=myHttpWebRequest.GetRequestStream();
Console.WriteLine("\nData has been posted to the Uri\n\nPlease wait for the response..........");
// Assign the response object of 'HttpWebRequest' to a 'HttpWebResponse' variable.
HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse();

.NET Framework
Available since 1.1
Available since 4.0
Windows Phone Silverlight
Available since 8.0
Return to top