.NET Framework Reading GET response as string using System.Net.HttpClient


Example

HttpClient is available through NuGet: Microsoft HTTP Client Libraries.

string requestUri = "http://www.example.com";
string responseData;

using (var client = new HttpClient())
{
    using(var response = client.GetAsync(requestUri).Result)
    {
       response.EnsureSuccessStatusCode();
       responseData = response.Content.ReadAsStringAsync().Result;
    }
}