I have the following code:
// Create POST data and convert it to a byte array.
string postData = "name=t&description=tt";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
using (StreamReader reader = new StreamReader(request.GetRequestStream()))
{
string s = reader.ReadToEnd();
}
When the flow hits the using (..... ) statement, I get the following exception:
Stream was not readable
I want to read the entire request stream into a string, nothing is closed, so the code should work?