ASP.NET Core | Making a request synchronously

using (var netClient = new System.Net.Http.HttpClient())
{
    var response = netClient.GetAsync("https://example.com").Result;

    if (response.IsSuccessStatusCode)
    {
        var responseContent = response.Content;

        string responseAsString = responseContent.ReadAsStringAsync().Result;

        Console.WriteLine(responseAsString);
    }
}

Leave a Comment

Your email address will not be published. Required fields are marked *