StreamReader ReadToEnd() after HttpWebRequest EndGetResponse() - most scalable?
Posted
by frankadelic
on Stack Overflow
See other posts from Stack Overflow
or by frankadelic
Published on 2010-01-18T22:26:41Z
Indexed on
2010/03/23
0:01 UTC
Read the original article
Hit count: 466
I am calling a RESTful web service in the back-end of some ASP.NET pages.
I am using ASP.NET asynchronous pages, so under the hood I am using the methods:
HttpWebRequest BeginGetResponse()
and
HttpWebRequest EndGetResponse()
The response string in my case is always a JSON string. I use the following code to read the entire string:
using (StreamReader sr = new StreamReader(myHttpWebResponse.GetResponseStream()))
{
myObject.JSONData = sr.ReadToEnd();
}
Is this method OK in terms of scalability? I have seen other code samples that instead retrieve the response data in blocks using Read(). My primary goal is scalability, so this back-end call can be made across many concurrent page hits.
Thanks, Frank
© Stack Overflow or respective owner