I am sending a request to Facebook Graph API by using WebClient with the following code that is written in an ASP.net MVC Controller class:
WebClient client2 = new WebClient();
Stream data2 = client2.OpenRead("https://graph.facebook.com/me&" + s);
StreamReader reader2 = new StreamReader(data); //Error
string s2 = reader2.ReadToEnd();
data2.Close();
reader2.Close();
s2=s2.Substring(s2.IndexOf('"', s2.IndexOf(':')), s2.Length - s2.IndexOf('"', s2.IndexOf(':')));
s2= s2.Substring(1, s2.IndexOf('"', 1) - 1);
return "AccessToken Stored in session, Current Signed in user is: "+s2;
I am getting this error: "System.ArgumentException: Stream was not readable." at the line commented as //Error. This request to https://graph.facebook.com returns data in JSON format. Is that causing this exception? Please help. How do I resolve this issue?