Consuming Web Services Using HTTP Clients and Getting Consumers
Understand how to consume web services using the HttpClient class and HttpClientFactory in .NET applications. Explore proper HttpClient usage, how to configure clients for different endpoints, and implement MVC controller methods to fetch and display data from web APIs.
Now that we have built and tested our Northwind service, we will learn how to call it from any .NET app using the HttpClient class and its factory.
Understanding HttpClient
The easiest way to consume a web service is to use the HttpClient class. However, many people use it wrongly because it implements IDisposable , and Microsoft’s own documentation shows poor usage of it.
Usually, when a type implements IDisposable, we should ...