using System.Net.Http; using Newtonsoft.Json; public async TaskGetJsonFromUrlAsync(string url) { using (HttpClient httpClient = new HttpClient()) { using (HttpResponseMessage response = await httpClient.GetAsync(url)) { using (HttpContent content = response.Content) { string json = await content.ReadAsStringAsync(); dynamic jsonObject = JsonConvert.DeserializeObject(json); return jsonObject; } } } }
using System.Net.Http; public async TaskPackage/Library: The package/library used for the examples above is the System.Net.Http package which is included in the .NET Standard Library.GetHtmlFromUrlAsync(string url) { using (HttpClient httpClient = new HttpClient()) { using (HttpResponseMessage response = await httpClient.GetAsync(url)) { using (HttpContent content = response.Content) { string html = await content.ReadAsStringAsync(); return html; } } } }