ASP.NET Core 3 combines the best features of ASP.NET MVC and web APIs into a single framework. This makes complete sense since they provide many similar functionalities.
Before this merger, developers had to rewrite code when they needed to expose data in different formats via MVC and web APIs. They had to work with multiple frameworks and concepts at the same time. Fortunately, this entire process has been completely streamlined in ASP.NET Core 3, as you will see in this chapter.
The following diagram illustrates how client HTTP requests are handled by ASP.NET Core 3 in terms of web APIs and MVC:
Web APIs normally use either JSON or XML as a response format. JSON is the preferred format since it has become a quasi-standard on the market and most modern applications use it due to its simplicity and efficiency.
Furthermore, filters and middleware can be used with web APIs since ASP.NET Core 3 manages web APIs the same way it does for standard MVC Controllers. This can be quite handy in some use cases and developers can apply their skills more widely.
In general, there are three different styles for creating web APIs when using ASP.NET Core 3:
- RPC-style
- REST-style
- HATEOAS-style
We will present each style in more detail, along with some practical examples, which will help you decide on your own integration strategy.