After searching silverlight forums I found a solution. The solution assumes that you have a control on the server code or the response you are getting is bigger than 4KB (IE buffers upto 4KB).
Here is the code snipped for your client side:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "POST";
request.AllowReadStreamBuffering = false;
catch (Exception excp)
void OnResponseReady(IAsyncResult result)
HttpWebResponse response = request.EndGetResponse(result) as HttpWebResponse;
Stream stream = response.GetResponseStream();
string responseText = null;
using (StreamReader sr = new StreamReader(stream))
char buffer = new Char;
int nByte = sr.Read(buffer, 0, buffer.Length);
while (nByte > 0)
responseText = new String(buffer, 0, nByte);
//read next piece
nByte = sr.Read(buffer, 0, buffer.Length);
Note that I do not call sr.ReadToEnd. If I do that then it blocks on this call until the whole response is received.
There is one gotcha as pointed out here: http://blog.lfdx.com/blogengine.net/post/HttpWebRequestAllowReadStreamBuffering3dfalse-Still-buffering-up-to-4kb!.aspx
The response is buffered in IE until it is bigger than 4KB. Therefore, if you have access to the server code then you need to change it to send 4KB garbage data before it starts sending meaningful stuff. If you do not have access to the server code then your code will be able to access streamign data only if it is bigger than 4KB.
This is such a fundamental and hidden feature. I want people to know and use it so we can all start finding other gotcha's if there are any more.