This documentation is archived and is not being maintained.

HttpWebRequest.AllowWriteStreamBuffering Property

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 Property AllowWriteStreamBuffering As Boolean
Dim instance As HttpWebRequest
Dim value As Boolean

value = instance.AllowWriteStreamBuffering

instance.AllowWriteStreamBuffering = value
/** @property */
public boolean get_AllowWriteStreamBuffering ()

/** @property */
public void set_AllowWriteStreamBuffering (boolean value)

public function get AllowWriteStreamBuffering () : boolean

public function set AllowWriteStreamBuffering (value : boolean)

Property Value

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.

Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows CE Platform Note: For performance considerations, the default value for this property is false; however, it is important to note that if verbs require entity data (such as POST), redirection and authentication might not occur. To implement the full .NET Framework behavior for HTTP requests, set AllowWriteStreamBuffering to true.

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

 ' A new 'HttpWebRequest' object is created                 
 Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(""), HttpWebRequest)
' AllowWriteStreamBuffering is set to 'false' 
 myHttpWebRequest.AllowWriteStreamBuffering = False
 Console.WriteLine(ControlChars.Cr + "Please Enter the data to be posted to the ( uri:")
 Dim inputData As String = Console.ReadLine()
 Dim postData As String = "firstone" + ChrW(61) + inputData
 ' 'Method' property of 'HttpWebRequest' class is set to POST.
 myHttpWebRequest.Method = "POST"
 Dim encodedData As New ASCIIEncoding()
 Dim byteArray As Byte() = encodedData.GetBytes(postData)
 ' 'ContentType' property of the 'HttpWebRequest' class is set to "application/x-www-form-urlencoded".
 myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"
 ' If the AllowWriteStreamBuffering property of HttpWebRequest is set to false,then contentlength has to be set to length of data to be posted else Exception(411) Length required is raised.
 Dim newStream As Stream = myHttpWebRequest.GetRequestStream()
 newStream.Write(byteArray, 0, byteArray.Length)
 Console.WriteLine(ControlChars.Cr + "Data has been posted to the Uri" + ControlChars.Cr + ControlChars.Cr + "Please wait for the response..........")
 ' The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable.
 Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)

// Create a new 'HttpWebRequest' object to the mentioned Uri.                
HttpWebRequest myHttpWebRequest = (HttpWebRequest)
    + "next.asp"));
// 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();
ubyte 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();
newStream.Write(byteArray, 0, byteArray.length);
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)

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0