I was putting in some debugging code to test some things, and then the debug code didn\'t behave as expected. The example below is a simplified code to demonstrate my questi
StreamReader
calls Dispose
on given stream when disposed. To leave the stream open use the appropriate constructor for the StreamReader
.
Or better yet, just copy it to a buffer. From MSDN:
When reading from a Stream, it is more efficient to use a buffer that is the same size as the internal buffer of the stream.
See this question for example.
HttpContext.Current.Request.InputStream.Position=0;
Once you read the position goes to last value, from there its trying to read second time. So before you read, set the position to zero.
Hope it helps.