Sto cercando di ottenere il contenuto di HttpResponseMessage. Dovrebbe essere: {"message":"Action '' does not exist!","success":false}
, ma non so come estrarlo da HttpResponseMessage.Come ricevere contenuto/messaggio da HttpResponseMessage
HttpClient httpClient = new HttpClient();
HttpResponseMessage response = await httpClient.GetAsync("http://****?action=");
txtBlock.Text = Convert.ToString(response); //wrong!
In questo caso txtBlock avrebbe valore:
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Vary: Accept-Encoding
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Date: Wed, 10 Apr 2013 20:46:37 GMT
Server: Apache/2.2.16
Server: (Debian)
X-Powered-By: PHP/5.3.3-7+squeeze14
Content-Length: 55
Content-Type: text/html
}
Grazie, ma perché ottengo questo errore qui: "System.Net.Http.HttpResponseMessage' non contiene una definizione per 'GetResponseStream' e non è stato trovato alcun metodo di estensione 'GetResponseStream' che accetta un primo argomento di tipo 'System.Net.Http.HttpResponseMessage' " – Clem
@Klemzy - Perché lo si chiama in modo asincrono. Prova invece a utilizzare la proprietà 'Content'. Guarda [esempio qui] (http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh781239.aspx). Scorri fino al secondo passaggio. – Icemanind
Sì, ma non so come :) Scusa sono principiante in C# – Clem