DocSas/DSCAppEssentials/Helpers/Utility.cs
/// <summary>
/// HTTP get item as an asynchronous operation.
/// </summary>
/// <param name="url">The URL.</param>
/// <returns>Task&lt;System.String&gt;.</returns>
HTTP get item as an asynchronous operation.
HTTP get item as an asynchronous operation .
public static async Task<string> HttpGetItemAsync(string url)
        {
            string result = string.Empty;
            using (HttpClient client = new HttpClient())
            {
                using (HttpResponseMessage response = await client.GetAsync(url))
                {
                    using (HttpContent content = response.Content)
                    {
                        string data = await content.ReadAsStringAsync();
                        if (!string.IsNullOrWhiteSpace(data))
                        {
                            result = data;
                        }
                    }
                }
            }
            return result;
        }
public static async Task < string > HttpGetItemAsync ( string url ) { string result = string . Empty ; using ( HttpClient client = new HttpClient ( ) ) { using ( HttpResponseMessage response = await client . GetAsync ( url ) ) { using ( HttpContent content = response . Content ) { string data = await content . ReadAsStringAsync ( ) ; if ( ! string . IsNullOrWhiteSpace ( data ) ) { result = data ; } } } } return result ; }
HTTP get item as an asynchronous operation.
HTTP get item as an asynchronous operation .
None
url
string
None