Warning: Cannot modify header information - headers already sent by (output started at /var/www/lalieno.it/index.php:48) in /var/www/lalieno.it/inc/cookie.php on line 3
a cadenza discontinua
Come se fossi
BLOG

[Visual Studio 2013 C# Windows Phone 8.1] - Richiesta Http tramite HttpClient

Di seguito un piccolo esempio di come eseguire una richiesta Http tramite HttpClient in C#.

// init
var myHttpClient = new HttpClient();

// await request the function must be async
var request = await myHttpClient.GetAsync(new Uri("http://miosito.it/index.php?nocache=" + Guid.NewGuid(), UriKind.RelativeOrAbsolute));
        
// response
var response = await request.Content.ReadAsStringAsync();

Aggiungendo nocache=" + Guid.NewGuid() possiamo disabilitare la cache, cosa utile nel momento in cui dobbiamo effettuare una richiesta frequentemente.


di GuiZ
04/02/2015

Commenta

We'll never share your email with anyone else.