In the old .NET version, we can consume Web Api from
HttpClient client = new HttpClient(); client.BaseAddress = new Uri("http://localhost:30151/"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //List all Customers HttpResponseMessage response = client.GetAsync("api/customers").Result; if (response.IsSuccessStatusCode) { var customers = response.Content.ReadAsAsync<IEnumerable<Customer>>().Result; foreach (var c in customers) { Console.WriteLine("ID: {0}\tName: {1}\tAddress: {2}\tEmail: {3}\tPhone: {4}", c.id, c.name, c.address, c.email, c.phone); } } else { Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase); } Console.Read();
Now if using .net coreclr. Is there a replacement for that?